@stalfh233/omc-cli 0.8.13 → 0.8.15
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/artifacts.js +3 -2
- package/dist/call.js +31 -0
- package/dist/cli-output.js +19 -0
- package/dist/cli.js +186 -23
- package/dist/form-support.js +3 -1
- package/dist/human-summary.js +84 -2
- package/dist/intent/capabilities/datarule.js +126 -12
- package/dist/intent/cli.js +35 -2
- package/dist/intent/compare.js +18 -0
- package/dist/intent/plan-apply.js +19 -5
- package/dist/intent/plan-file.js +38 -0
- package/dist/intent/readback.js +3 -0
- package/dist/intent/schema.js +1 -1
- package/dist/lanes/datarule-contract.js +2 -1
- package/dist/lanes/datarule.js +59 -2
- package/dist/lanes/environment.js +43 -3
- package/dist/lanes/field-contract.js +1 -1
- package/dist/lanes/field.js +17 -2
- package/dist/lanes/form.js +1 -1
- package/dist/lanes/model-references.js +29 -1
- package/dist/lanes/runtime-data-contract.js +2 -2
- package/dist/lanes/runtime-data.js +328 -31
- package/dist/lanes/workflow.js +79 -2
- package/dist/model-purge.js +2 -13
- package/dist/mojibake.js +69 -0
- package/dist/read-shapes.js +2 -1
- package/dist/recipes/datarule.js +1 -0
- package/dist/recipes/form.js +2 -2
- package/dist/recipes/runtime-data.js +4 -4
- package/dist/stdout-pipe.js +78 -0
- package/dist/tool-types.js +10 -0
- package/dist/write.js +56 -7
- package/package.json +3 -3
- package/skills/omc-business-configuration.md +1 -1
- package/skills/omc-capabilities.md +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ENDPOINTS } from "../../endpoints.js";
|
|
2
2
|
import { assertDataRuleOptions } from "../../lanes/datarule.js";
|
|
3
3
|
import { wireCall, wireRows } from "../../wire.js";
|
|
4
|
-
import { optionalSame, sameValue } from "../compare.js";
|
|
4
|
+
import { optionalSame, sameValue, sortKeySame } from "../compare.js";
|
|
5
5
|
import { isScalarString, pushError } from "../validation.js";
|
|
6
6
|
import { toPlain } from "../yaml.js";
|
|
7
|
-
import { errorDetail } from "../../tool-types.js";
|
|
7
|
+
import { errorDetail, ToolRefusalError } from "../../tool-types.js";
|
|
8
8
|
const KEYS = new Set(["propertyCode", "dataRuleType", "options", "checkType", "childRule", "name", "sortKey", "absent"]);
|
|
9
9
|
/** Keys that describe a live rule and are meaningless on a declared-absent one. */
|
|
10
10
|
const PRESENT_ONLY_KEYS = ["options", "checkType", "childRule", "name", "sortKey"];
|
|
@@ -28,12 +28,96 @@ function rowOf(row) {
|
|
|
28
28
|
...(row.checkType !== undefined && row.checkType !== null ? { checkType: Number(row.checkType) } : {}),
|
|
29
29
|
...(row.childRule !== undefined ? { childRule: row.childRule === true } : {}),
|
|
30
30
|
...(row.name !== undefined && row.name !== null ? { name: String(row.name) } : {}),
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
...(row.sortKey !== undefined && row.sortKey !== null && Number(row.sortKey) !== 0 ? { sortKey: Number(row.sortKey) } : {}),
|
|
31
|
+
// Keep the platform's value verbatim (including 0): equivalence is decided
|
|
32
|
+
// by `sortKeySame`, which ignores it when the intent did not declare one.
|
|
33
|
+
...(row.sortKey !== undefined && row.sortKey !== null ? { sortKey: Number(row.sortKey) } : {}),
|
|
35
34
|
};
|
|
36
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Declared rule identity. For present rules the intent's declared `checkType`
|
|
38
|
+
* is part of the key: the platform seeds type1/checkType1..5 rules from field
|
|
39
|
+
* options (e.g. `maxLength` → type1/checkType4, `DataModelInitUtils:406-416`),
|
|
40
|
+
* so matching on `(propertyCode, dataRuleType)` alone made a user rule target
|
|
41
|
+
* the platform's auto row and silently rewrite it.
|
|
42
|
+
*
|
|
43
|
+
* A declared-absent rule carries no shape keys (validation forbids checkType),
|
|
44
|
+
* so delete keeps the historical `(propertyCode, dataRuleType)` identity.
|
|
45
|
+
*
|
|
46
|
+
* The checkType half is compared strictly (undeclared = `null`). A type1 auto
|
|
47
|
+
* row always has a numeric checkType 1..5, so an intent that omits checkType
|
|
48
|
+
* can never match — and therefore never update — a platform-seeded rule.
|
|
49
|
+
*/
|
|
50
|
+
function matchesDeclaredRule(rule, row) {
|
|
51
|
+
if (row.propertyCode !== rule.propertyCode || row.dataRuleType !== rule.dataRuleType)
|
|
52
|
+
return false;
|
|
53
|
+
if (rule.absent === true)
|
|
54
|
+
return true;
|
|
55
|
+
return (row.checkType ?? null) === (rule.checkType ?? null);
|
|
56
|
+
}
|
|
57
|
+
function candidateOf(row) {
|
|
58
|
+
return { id: row.id, ...(row.name !== undefined ? { name: row.name } : {}), ...(row.checkType !== undefined ? { checkType: row.checkType } : {}) };
|
|
59
|
+
}
|
|
60
|
+
function listRuleCommand(schemaCode, dataRuleType) {
|
|
61
|
+
return `omc call datarule.list --env <env> --args '${JSON.stringify({ schemaCode, dataRuleType })}'`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Two live rows match the declared identity. Never pick one: the platform's
|
|
65
|
+
* auto-seeded rules and a user rule can share `(propertyCode, dataRuleType)`,
|
|
66
|
+
* and guessing is exactly how an apply silently rewrote the wrong row.
|
|
67
|
+
*/
|
|
68
|
+
function ambiguousRefusal(schemaCode, rule, rows) {
|
|
69
|
+
const candidates = rows.map(candidateOf);
|
|
70
|
+
const nextCommand = listRuleCommand(schemaCode, rule.dataRuleType);
|
|
71
|
+
const checkLabel = rule.checkType !== undefined ? ` / checkType ${rule.checkType}` : "";
|
|
72
|
+
return new ToolRefusalError({
|
|
73
|
+
status: "refused",
|
|
74
|
+
blocker: "datarule-ambiguous",
|
|
75
|
+
resource: `datarule:${schemaCode}.${rule.propertyCode}.${rule.dataRuleType}`,
|
|
76
|
+
propertyCode: rule.propertyCode,
|
|
77
|
+
dataRuleType: rule.dataRuleType,
|
|
78
|
+
...(rule.checkType !== undefined ? { checkType: rule.checkType } : {}),
|
|
79
|
+
candidates,
|
|
80
|
+
message: `字段 ${schemaCode}.${rule.propertyCode} 的 dataRuleType ${rule.dataRuleType}${checkLabel} 有 ${rows.length} 条同键规则,无法判定声明目标;本次零写入。先列出候选,声明 checkType 消歧;平台自动规则需改走 omc call datarule.update --args '{"id":"<候选 id>",...}'`,
|
|
81
|
+
nextCommand,
|
|
82
|
+
options: [
|
|
83
|
+
{ id: "read-only", destructive: false, summary: "保留现有行,先列出候选;本次未写入任何配置", readFirst: nextCommand },
|
|
84
|
+
{ id: "edit-intent", destructive: false, summary: "给 intent 的 datarule 补 checkType(type1 的校验类别)消歧后重新 plan;平台自动规则(如 maxLength 生成的 type1/checkType4)不要作为 update 目标" },
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Declared-vs-live drift with the exact key/value pairs that differ.
|
|
90
|
+
* `sortKey` only participates when the intent declares it (the platform owns
|
|
91
|
+
* the default order: first rule = 1, then max+1, per
|
|
92
|
+
* `BizDataRuleFacadeImpl.addBizDataRule:98-110`). The returned `expected` /
|
|
93
|
+
* `actual` make the difference actionable instead of a bare "不等价".
|
|
94
|
+
*/
|
|
95
|
+
function ruleMismatch(rule, row) {
|
|
96
|
+
const expected = {};
|
|
97
|
+
const actual = {};
|
|
98
|
+
if (!sameValue(optionsForComparison(rule.options, row.options), rule.options)) {
|
|
99
|
+
expected.options = rule.options;
|
|
100
|
+
actual.options = row.options;
|
|
101
|
+
}
|
|
102
|
+
if (!optionalSame(row.checkType, rule.checkType)) {
|
|
103
|
+
expected.checkType = rule.checkType ?? null;
|
|
104
|
+
actual.checkType = row.checkType ?? null;
|
|
105
|
+
}
|
|
106
|
+
if (!optionalSame(row.childRule, rule.childRule)) {
|
|
107
|
+
expected.childRule = rule.childRule ?? null;
|
|
108
|
+
actual.childRule = row.childRule ?? null;
|
|
109
|
+
}
|
|
110
|
+
if (!optionalSame(row.name, rule.name)) {
|
|
111
|
+
expected.name = rule.name ?? null;
|
|
112
|
+
actual.name = row.name ?? null;
|
|
113
|
+
}
|
|
114
|
+
if (!sortKeySame(rule.sortKey, row.sortKey)) {
|
|
115
|
+
expected.sortKey = rule.sortKey ?? null;
|
|
116
|
+
actual.sortKey = row.sortKey ?? null;
|
|
117
|
+
}
|
|
118
|
+
const keys = Object.keys(expected);
|
|
119
|
+
return keys.length > 0 ? { keys, expected, actual } : null;
|
|
120
|
+
}
|
|
37
121
|
function normalizeOptions(dataRuleType, options, propertyCode) {
|
|
38
122
|
const normalized = { ...options };
|
|
39
123
|
// The tool mirrors the target field(s) into options.propertyCodes (the real
|
|
@@ -157,24 +241,38 @@ export const dataruleCapability = {
|
|
|
157
241
|
if (!intent.datarules?.length)
|
|
158
242
|
return;
|
|
159
243
|
const rows = wireRows((await wireCall(session, { path: ENDPOINTS.dataRuleList, query: { schemaCode: draft.code } })).data);
|
|
160
|
-
draft.datarules = rows
|
|
244
|
+
draft.datarules = rows
|
|
245
|
+
.filter((row) => row.schemaCode === draft.code)
|
|
246
|
+
.filter((row) => {
|
|
247
|
+
const dataRuleType = Number(row.dataRuleType);
|
|
248
|
+
const checkType = row.checkType !== undefined && row.checkType !== null ? Number(row.checkType) : undefined;
|
|
249
|
+
return rowCodes(row).some((propertyCode) => intent.datarules.some((rule) => matchesDeclaredRule(rule, { propertyCode, dataRuleType, ...(checkType !== undefined ? { checkType } : {}) })));
|
|
250
|
+
})
|
|
251
|
+
.map(rowOf);
|
|
161
252
|
},
|
|
162
253
|
plan(intent, baseline, emit) {
|
|
163
254
|
if (!intent.datarules?.length)
|
|
164
255
|
return;
|
|
165
256
|
for (const rule of intent.datarules) {
|
|
166
|
-
const
|
|
257
|
+
const candidates = (baseline.datarules ?? []).filter((row) => matchesDeclaredRule(rule, row));
|
|
167
258
|
const resource = `datarule:${intent.code}.${rule.propertyCode}.${rule.dataRuleType}`;
|
|
168
259
|
if (rule.absent === true) {
|
|
260
|
+
const current = candidates[0];
|
|
169
261
|
if (current)
|
|
170
262
|
emit.change("datarule.delete", { id: current.id, schemaCode: intent.code }, resource, "datarule-declared-absent");
|
|
171
263
|
else
|
|
172
264
|
emit.skip(resource, "datarule-already-absent");
|
|
173
265
|
continue;
|
|
174
266
|
}
|
|
267
|
+
// Never guess between two same-key rows (platform auto rule + user rule).
|
|
268
|
+
// Throwing here aborts the whole compile with zero writes (plan payload is
|
|
269
|
+
// a refusal; arrays are local to compileIntent).
|
|
270
|
+
if (candidates.length > 1)
|
|
271
|
+
throw ambiguousRefusal(intent.code, rule, candidates);
|
|
272
|
+
const current = candidates[0];
|
|
175
273
|
if (!current)
|
|
176
274
|
emit.change("datarule.create", { schemaCode: intent.code, ...rule }, resource, "datarule-absent");
|
|
177
|
-
else if (
|
|
275
|
+
else if (ruleMismatch(rule, current) !== null)
|
|
178
276
|
emit.change("datarule.update", { id: current.id, schemaCode: intent.code, ...rule }, resource, "datarule-drift");
|
|
179
277
|
else
|
|
180
278
|
emit.skip(resource, "datarule-present");
|
|
@@ -188,17 +286,33 @@ export const dataruleCapability = {
|
|
|
188
286
|
return;
|
|
189
287
|
const current = live.datarules ?? [];
|
|
190
288
|
for (const rule of intent.datarules) {
|
|
191
|
-
const
|
|
289
|
+
const candidates = current.filter((item) => matchesDeclaredRule(rule, item));
|
|
290
|
+
const row = candidates[0];
|
|
192
291
|
const resource = `datarule:${intent.code}.${rule.propertyCode}.${rule.dataRuleType}`;
|
|
193
292
|
if (rule.absent === true) {
|
|
194
293
|
if (row)
|
|
195
294
|
emit.difference("datarule-present-unexpected", resource, `字段 ${intent.code}.${rule.propertyCode} 的数据规则声明 absent:true 但仍存在`);
|
|
196
295
|
continue;
|
|
197
296
|
}
|
|
297
|
+
if (candidates.length > 1) {
|
|
298
|
+
// Mirrors the plan-time refusal: a converged-looking environment with
|
|
299
|
+
// two same-key rows never gets a guessed pass/fail.
|
|
300
|
+
emit.difference("datarule-mismatch", resource, `字段 ${intent.code}.${rule.propertyCode} 的 dataRuleType ${rule.dataRuleType} 有 ${candidates.length} 条同键规则,无法判定声明目标`, {
|
|
301
|
+
keys: ["candidates"],
|
|
302
|
+
expected: { candidates: 1 },
|
|
303
|
+
actual: { candidates: candidates.map(candidateOf) },
|
|
304
|
+
sourceTool: "datarule.list",
|
|
305
|
+
next: { kind: "call", command: listRuleCommand(intent.code, rule.dataRuleType) },
|
|
306
|
+
});
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
198
309
|
if (!row)
|
|
199
310
|
emit.difference("datarule-missing", resource, `字段 ${intent.code}.${rule.propertyCode} 的数据规则不存在`);
|
|
200
|
-
else
|
|
201
|
-
|
|
311
|
+
else {
|
|
312
|
+
const mismatch = ruleMismatch(rule, row);
|
|
313
|
+
if (mismatch !== null)
|
|
314
|
+
emit.difference("datarule-mismatch", resource, `字段 ${intent.code}.${rule.propertyCode} 的数据规则不等价(${mismatch.keys.join("、")})`, { keys: mismatch.keys, expected: mismatch.expected, actual: mismatch.actual });
|
|
315
|
+
}
|
|
202
316
|
}
|
|
203
317
|
},
|
|
204
318
|
};
|
package/dist/intent/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { resolve } from "node:path";
|
|
1
|
+
import { lstatSync, readFileSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, resolve } from "node:path";
|
|
3
3
|
import { assertSafeInputPath } from "../artifacts.js";
|
|
4
4
|
import { CLI_ARGS_MAX_BYTES } from "../call.js";
|
|
5
5
|
import { INTENT_VERSION, parseIntent, YamlSyntaxError, IntentInvalidError } from "./dsl.js";
|
|
@@ -15,6 +15,39 @@ export function readIntentFile(root, path) {
|
|
|
15
15
|
throw new Error(`intent file exceeds ${CLI_ARGS_MAX_BYTES} bytes`);
|
|
16
16
|
return content;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Probe I F1(0.8.15):`intent apply` 的输入是**plan 文件**,不是意图源文件。
|
|
20
|
+
* plan 是 CLI 自己写出的产物(`--out`/`--plan-out`/artifact),不含凭据,因此
|
|
21
|
+
* 允许配置根外的路径(至少 /tmp)——否则 CLI 刚写出的文件会被自己拒绝。
|
|
22
|
+
* 仍守住形状:拒绝符号链接(只查叶节点,不逐段)、非普通文件、超大文件;
|
|
23
|
+
* 相对路径先按配置根解析(与旧行为兼容:`intent apply plan.json` 仍指向根内),
|
|
24
|
+
* 再按当前目录解析。意图源 YAML(validate/plan/readback)维持 `readIntentFile`
|
|
25
|
+
* 的根内限制。
|
|
26
|
+
*/
|
|
27
|
+
export function readPlanFile(root, path) {
|
|
28
|
+
const candidates = isAbsolute(path) ? [path] : [resolve(root, path), resolve(path)];
|
|
29
|
+
let lastError;
|
|
30
|
+
for (const candidate of [...new Set(candidates)]) {
|
|
31
|
+
try {
|
|
32
|
+
const stat = lstatSync(candidate);
|
|
33
|
+
if (stat.isSymbolicLink())
|
|
34
|
+
throw new Error(`plan 文件不能是符号链接:${candidate}`);
|
|
35
|
+
if (!stat.isFile())
|
|
36
|
+
throw new Error(`plan 文件必须是常规文件:${candidate}`);
|
|
37
|
+
if (stat.size > CLI_ARGS_MAX_BYTES)
|
|
38
|
+
throw new Error(`plan 文件超过 ${CLI_ARGS_MAX_BYTES} 字节:${candidate}`);
|
|
39
|
+
const content = readFileSync(candidate, "utf8");
|
|
40
|
+
if (Buffer.byteLength(content) > CLI_ARGS_MAX_BYTES)
|
|
41
|
+
throw new Error(`plan 文件超过 ${CLI_ARGS_MAX_BYTES} 字节:${candidate}`);
|
|
42
|
+
return content;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
lastError = error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const detail = lastError instanceof Error ? `(${lastError.message})` : "";
|
|
49
|
+
throw new Error(`plan 文件不存在或不可读:${path}${detail}`);
|
|
50
|
+
}
|
|
18
51
|
/** Validate an intent file's text offline (zero environment contact). */
|
|
19
52
|
export function validateIntentText(text) {
|
|
20
53
|
try {
|
package/dist/intent/compare.js
CHANGED
|
@@ -35,6 +35,24 @@ export function canonicalValue(value) {
|
|
|
35
35
|
export function sameValue(left, right) {
|
|
36
36
|
return canonicalValue(left) === canonicalValue(right);
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Equivalence for a platform-owned ordering column. The platform ASSIGNS
|
|
40
|
+
* `sortKey` on insert (first rule = 1, then max+1 — see
|
|
41
|
+
* `BizDataRuleFacadeImpl.addBizDataRule`, 8.6.26 :98-110 and 2.1.5 :116-133);
|
|
42
|
+
* the value is not derived from the caller. So an intent that omits `sortKey`
|
|
43
|
+
* accepts whatever order the platform backfilled; only an explicitly declared
|
|
44
|
+
* value is compared.
|
|
45
|
+
*
|
|
46
|
+
* Probe H F1: the platform backfilled `sortKey:1` on the first rule while the
|
|
47
|
+
* intent omitted it, so comparing `undefined` against `1` made a fully applied
|
|
48
|
+
* environment report `datarule-mismatch`, and every re-plan re-sent the
|
|
49
|
+
* update — plan/apply never converged.
|
|
50
|
+
*/
|
|
51
|
+
export function sortKeySame(declared, live) {
|
|
52
|
+
if (declared === undefined || declared === null)
|
|
53
|
+
return true;
|
|
54
|
+
return sameValue(declared, live);
|
|
55
|
+
}
|
|
38
56
|
/**
|
|
39
57
|
* Equivalence for an optional field: a missing value equals the platform's
|
|
40
58
|
* `false` default in EITHER direction. The real platform stores `childRule:false`
|
|
@@ -18,13 +18,13 @@ import { ENDPOINTS } from "../endpoints.js";
|
|
|
18
18
|
import { extractBizObjectPage } from "../lanes/runtime-data.js";
|
|
19
19
|
import { ToolRefusalError, ToolInputError, parseToolInput } from "../tool-types.js";
|
|
20
20
|
import { jsonBytes, sha256, writeArtifact } from "../support.js";
|
|
21
|
-
import { INTENT_COMPILER_VERSION, intentConfigRoot,
|
|
21
|
+
import { INTENT_COMPILER_VERSION, intentConfigRoot, readPlanFile } from "./cli.js";
|
|
22
22
|
import { validateRuleNodeGraph, PLATFORM_TRIGGER_RULE_CODES, walkConditionLeaves } from "../lanes/rule-graph.js";
|
|
23
23
|
import { expectedRuleGraph } from "./capabilities/businessrule.js";
|
|
24
24
|
import { lintIntentFieldCreateChanges, relationTargetsFromPlan } from "./capabilities/field.js";
|
|
25
25
|
import { readBaseline, baselineFingerprintOf } from "./baseline.js";
|
|
26
26
|
import { compileIntent } from "./compiler.js";
|
|
27
|
-
import { buildPlan, verifyPlan } from "./plan-file.js";
|
|
27
|
+
import { buildPlan, unwrapPlanDocument, verifyPlan } from "./plan-file.js";
|
|
28
28
|
import { decodeBaseline, compareWithLive } from "./readback.js";
|
|
29
29
|
const INTENT_PLAN_INLINE_CEILING_BYTES = 16384;
|
|
30
30
|
/**
|
|
@@ -398,7 +398,9 @@ export async function applyIntent(planPath, options, ports) {
|
|
|
398
398
|
const invalid = (blocker, message, code = "invalid-input") => ports.invalid(blocker, message, code);
|
|
399
399
|
let planText;
|
|
400
400
|
try {
|
|
401
|
-
|
|
401
|
+
// Probe I F1(0.8.15):plan 是 CLI 产物(`--out`/`--plan-out` 都可能落在任何
|
|
402
|
+
// 路径),不能按意图源文件的「配置根内」规则拒绝自己刚写出的文件。
|
|
403
|
+
planText = readPlanFile(intentConfigRoot(), planPath);
|
|
402
404
|
}
|
|
403
405
|
catch (fileError) {
|
|
404
406
|
// The plan for a large intent is externalized: `intent plan` returns
|
|
@@ -411,8 +413,8 @@ export async function applyIntent(planPath, options, ports) {
|
|
|
411
413
|
}
|
|
412
414
|
catch {
|
|
413
415
|
const hint = planPath.endsWith(".json") || planPath.includes("/") || planPath.includes("\\")
|
|
414
|
-
? "plan
|
|
415
|
-
: `plan 找不到 "${planPath}"。大 plan 会外置——用 intent plan 结果里的 planFile 路径或 artifactId(可直接 \`omc intent apply <artifactId>\`);小 plan 内联在 result.plan
|
|
416
|
+
? "plan 文件不存在或不可读(plan 可在配置根外,如 /tmp;意图源 YAML 仍须在配置根内);plan 产物里有 planFile/artifactId 两种引用,直接给 planFile 或 artifactId 均可"
|
|
417
|
+
: `plan 找不到 "${planPath}"。大 plan 会外置——用 intent plan 结果里的 planFile 路径或 artifactId(可直接 \`omc intent apply <artifactId>\`);小 plan 内联在 result.plan,用 --out 写的信封也可直接 apply(自动取 result.plan)`;
|
|
416
418
|
return invalid(undefined, `${hint}(原错误:${fileError instanceof Error ? fileError.message : String(fileError)})`);
|
|
417
419
|
}
|
|
418
420
|
}
|
|
@@ -428,6 +430,10 @@ export async function applyIntent(planPath, options, ports) {
|
|
|
428
430
|
// SOURCE intent YAML directly: compile it in-process (same pipeline as
|
|
429
431
|
// `intent plan`) and apply the resulting plan.
|
|
430
432
|
const read = ports.readIntent ? ports.readIntent(planPath) : undefined;
|
|
433
|
+
// 意图源定位/校验错误(最典型:YAML 在配置根外)优先于 JSON.parse 的
|
|
434
|
+
// `Unexpected token`——根限制是可执行的修法,解析噪声只会盖住它。
|
|
435
|
+
if (read && read.kind === "invalid")
|
|
436
|
+
return invalid(undefined, read.message);
|
|
431
437
|
if (read && read.kind === "ok") {
|
|
432
438
|
try {
|
|
433
439
|
const context = makeToolContext({ sessions: new SessionManager(new ConfigStore(defaultPaths())) });
|
|
@@ -452,6 +458,14 @@ export async function applyIntent(planPath, options, ports) {
|
|
|
452
458
|
return invalid(undefined, `plan 文件不是合法 JSON:${error instanceof Error ? error.message : String(error)};意图 YAML 请先 intent plan <yaml> --plan-out <plan.json>,或直接 intent apply <yaml> --env <env>(自动编译)`);
|
|
453
459
|
}
|
|
454
460
|
}
|
|
461
|
+
// Probe I F2(0.8.15):`--out` 落的是完整 CLI 信封;apply 自动取 result.plan
|
|
462
|
+
// (或 result 本身是 plan)。裸 plan(schema 在顶层)原样通过。
|
|
463
|
+
const unwrapped = unwrapPlanDocument(parsed);
|
|
464
|
+
if (!unwrapped.ok)
|
|
465
|
+
return invalid(unwrapped.envelope ? "intent-plan-envelope-without-plan" : undefined, unwrapped.reason);
|
|
466
|
+
if (unwrapped.document.fromEnvelope)
|
|
467
|
+
console.error("intent apply:输入是 CLI 信封,已自动取 result.plan");
|
|
468
|
+
parsed = unwrapped.document.plan;
|
|
455
469
|
const verified = verifyPlan(parsed);
|
|
456
470
|
if (!verified.ok)
|
|
457
471
|
return invalid(verified.code, verified.reason);
|
package/dist/intent/plan-file.js
CHANGED
|
@@ -61,4 +61,42 @@ export function verifyPlan(value) {
|
|
|
61
61
|
return { ok: false, code: "intent-plan-tampered", reason: "plan 哈希不匹配:文件内容与生成时不一致(what you approve must be byte-identical to what executes)" };
|
|
62
62
|
return { ok: true, plan: plan };
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Probe I F2(0.8.15):`omc intent plan ... --out <file>` 写的是**完整 CLI 信封**
|
|
66
|
+
* (`--out` 是全局信封落盘开关,不是 plan 专用选项),而 `intent apply` 只认裸
|
|
67
|
+
* plan,于是把外层当 plan 读、报 `plan.schema 必须是 omc-intent-plan-v1`。
|
|
68
|
+
* 这里只做文档定位,不校验哈希(verifyPlan 仍是唯一权威):
|
|
69
|
+
* - 裸 plan(`schema` 在顶层)→ 原样;
|
|
70
|
+
* - envelope 的 `result.plan` 或 `result` 本身是 plan → 取出来;
|
|
71
|
+
* - 是信封但取不到 plan → 明确说「你给的是信封,取 result.plan」。
|
|
72
|
+
*/
|
|
73
|
+
export function unwrapPlanDocument(value) {
|
|
74
|
+
if (value === null || typeof value !== "object" || Array.isArray(value))
|
|
75
|
+
return { ok: false, envelope: false, reason: "plan 文件必须是 JSON 对象" };
|
|
76
|
+
const record = value;
|
|
77
|
+
if (record.schema === INTENT_PLAN_SCHEMA)
|
|
78
|
+
return { ok: true, document: { plan: value, fromEnvelope: false } };
|
|
79
|
+
const result = record.result;
|
|
80
|
+
if (result !== null && typeof result === "object" && !Array.isArray(result)) {
|
|
81
|
+
const resultRecord = result;
|
|
82
|
+
if (resultRecord.schema === INTENT_PLAN_SCHEMA)
|
|
83
|
+
return { ok: true, document: { plan: result, fromEnvelope: true } };
|
|
84
|
+
const nested = resultRecord.plan;
|
|
85
|
+
if (nested !== null && typeof nested === "object" && !Array.isArray(nested) && nested.schema === INTENT_PLAN_SCHEMA)
|
|
86
|
+
return { ok: true, document: { plan: nested, fromEnvelope: true } };
|
|
87
|
+
}
|
|
88
|
+
const envelopeShaped = "ok" in record || "status" in record || "requestId" in record || "result" in record || "error" in record;
|
|
89
|
+
if (!envelopeShaped)
|
|
90
|
+
return { ok: true, document: { plan: value, fromEnvelope: false } };
|
|
91
|
+
// A large plan is externalized: the envelope carries only planFile/planArtifactId.
|
|
92
|
+
const external = result !== null && typeof result === "object" && !Array.isArray(result) ? result : undefined;
|
|
93
|
+
const reference = typeof external?.planArtifactId === "string"
|
|
94
|
+
? `planArtifactId=${external.planArtifactId}`
|
|
95
|
+
: typeof external?.planFile === "string"
|
|
96
|
+
? `planFile=${external.planFile}`
|
|
97
|
+
: undefined;
|
|
98
|
+
const reason = `检测到你给的是 CLI 信封(含 ok/result),但取不到其中的 plan(没有 result.plan,result 本身也不是 plan)——信封文件请取 result.plan 再 apply,或直接用 intent plan --plan-out <plan.json> 写裸 plan`
|
|
99
|
+
+ (reference !== undefined ? `;本次信封里 plan 已外置(${reference}),可直接 apply 该引用` : "");
|
|
100
|
+
return { ok: false, envelope: true, reason };
|
|
101
|
+
}
|
|
64
102
|
//# sourceMappingURL=plan-file.js.map
|
package/dist/intent/readback.js
CHANGED
|
@@ -81,6 +81,9 @@ function differenceOf(kind, resource, message, detail) {
|
|
|
81
81
|
...(next !== undefined ? { next } : {}),
|
|
82
82
|
...(escapeHatch !== undefined ? { escapeHatch } : {}),
|
|
83
83
|
...(safeToReplan !== undefined ? { safeToReplan } : {}),
|
|
84
|
+
...(detail?.expected !== undefined ? { expected: detail.expected } : {}),
|
|
85
|
+
...(detail?.actual !== undefined ? { actual: detail.actual } : {}),
|
|
86
|
+
...(detail?.keys !== undefined ? { keys: detail.keys } : {}),
|
|
84
87
|
};
|
|
85
88
|
}
|
|
86
89
|
/**
|
package/dist/intent/schema.js
CHANGED
|
@@ -148,7 +148,7 @@ export function intentSchemaBlock() {
|
|
|
148
148
|
},
|
|
149
149
|
form: { required: ["publish"], optional: ["fieldCodes"] },
|
|
150
150
|
listview: { required: [], optional: ["code", "name", "fieldCodes", "absent"], note: "intent 只声明列;业务筛选/排序/按钮 apply 后用 omc call listview.configure 补" },
|
|
151
|
-
datarules: { required: ["propertyCode", "dataRuleType"], optional: ["options", "checkType", "childRule", "name", "sortKey", "absent"], note: "type3/4/5 不驱动门户;门户条件走 fields[].options" },
|
|
151
|
+
datarules: { required: ["propertyCode", "dataRuleType"], optional: ["options", "checkType", "childRule", "name", "sortKey", "absent"], note: "type3/4/5 不驱动门户;门户条件走 fields[].options;未声明 sortKey=顺序归平台、不参与比较,显式声明才严格比较" },
|
|
152
152
|
rules: {
|
|
153
153
|
required: ["code", "name(预置触发行 Create/Update/Delete… 可省略,声明的 name 不会生效)", "enabled"],
|
|
154
154
|
optional: ["bizRuleType", "customTrigger", "actions", "nodeGraph"],
|
|
@@ -17,7 +17,7 @@ export const DATARULE_WIRE = Object.freeze({
|
|
|
17
17
|
delete: "bizdatarule/delete?id=<ruleId> (@RequestParam String id) with list exact-absence readback",
|
|
18
18
|
dataRuleTypes: "DataRuleType: 1 CHECK_RULE (校验), 2 CALCULATE_RULE (计算/拼接), 3 DISPLAY_RULE (显示), 4 OTHER_RULE (必填), 5 READ_ONLY_RULE (只读); 8 EXTENSION_RULE is out of scope",
|
|
19
19
|
dataRuleCheckTypes: "dataRuleType 1 (CHECK_RULE 提交校验规则) 的 checkType 判别(cloudpivot-shared DataRuleCheckType.java)——**校验类需求走这里,不要写在线 JS**:1 REGEX_CHECK 正则校验 / 2 SUBMIT_CHECK 提交校验(含跨字段比较)/ 3 EMPTY_ROW_CHECK 空行校验 / 4 MAX_LENGTH_CHECK 最大长度校验 / 5 REPEAT_CHECK 重复校验;checkType 只配 dataRuleType 1,缺省或非法值由工具拒绝。**数值上下限没有专用类型——用 checkType 2 提交校验表达(如 数量≥0:options 提交校验条件 {quantity}>=0,r21 实证)**",
|
|
20
|
-
optionsByCheckType: "各 checkType 的 options 白名单(工具会拒绝 unknownOptionKeys,避免平台静默忽略;运行版 1.1.25 SubmitCheckValidator/RepeatCheckValidator 反编译实证 2026-11-06):1 REGEX_CHECK{regexp,regexpText};2 SUBMIT_CHECK{conditions,verifyType,prompt}(verifyType 的拒用取值=submitDenied——它是 verifyType 的值,不是独立键);3 EMPTY_ROW_CHECK{isEmptyRow,isEmptyRowTips};4 MAX_LENGTH_CHECK{maxLength};5 REPEAT_CHECK{noRepeat,properties,isSubTableValidationAllData,prompt}。checkType-2 的 prompt 是纯文本(门户 raw 渲染 options.prompt,不做富文本解析)。重复提示逐项/数组解析,RepeatCheckValidator:258-272:isDataItem=0 → code 是字面文案;isDataItem=1 → code 是字段 code。checkType=5 的唯一去重键是 options.noRepeat(配合 properties),平台 REST 也会拦重复;conditions/regexp/maxLength
|
|
20
|
+
optionsByCheckType: "各 checkType 的 options 白名单(工具会拒绝 unknownOptionKeys,避免平台静默忽略;运行版 1.1.25 SubmitCheckValidator/RepeatCheckValidator 反编译实证 2026-11-06):1 REGEX_CHECK{regexp,regexpText};2 SUBMIT_CHECK{conditions,verifyType,prompt}(verifyType 的拒用取值=submitDenied——它是 verifyType 的值,不是独立键);3 EMPTY_ROW_CHECK{isEmptyRow,isEmptyRowTips};4 MAX_LENGTH_CHECK{maxLength};5 REPEAT_CHECK{noRepeat,properties,isSubTableValidationAllData,prompt}。checkType-2 的 prompt 是纯文本(门户 raw 渲染 options.prompt,不做富文本解析)。重复提示逐项/数组解析,RepeatCheckValidator:258-272:isDataItem=0 → code 是字面文案;isDataItem=1 → code 是字段 code。checkType=5 的唯一去重键是 options.noRepeat(配合 properties),平台 REST 也会拦重复;conditions/regexp/maxLength 等默认只在门户前端提交面执行(**dist 级证据**:同一表单 HTTP 模块在 admin `19497.069256cf.js` 与 portal-app `34987.2913aa1b.js` 为同名双份,过滤条件相同)。CLI `data.submit`/`data.save` 走 runtime/form,服务端 `DataRuleProcessor.checkMainNonNullProperty` 只对**空值**跑规则:非空 continue(2.1.5 :102 / 8.6.26 :115),null 才 `executeDataRules`(2.1.5 :112 / 8.6.26 :125),所以字段为空时仍可能按必填类错误拒。提交面只额外跑 checkType5 重复校验(BizFormRuntimeFacadeImpl.java:164)与 2.1.5 独有的 validateHiddenProperties 隐藏字段校验(AbstractFormRuntimeController.java:157-208;8.6.26/8.7 的 DataRuleOptions 无此键、不执行);条件校验只在 OpenAPI 表单保存入口 `BaseController.checkDataRules`(2.1.5 :1245-1281)执行。`data.submit` 按此分类回执:dataRulesNotExecuted{count,checkTypes,hiddenRulesPresent,autoLengthRules?};平台自动 type1+checkType4 长度规则不计入 count。",
|
|
21
21
|
optionsByType: "options is a JSON string read per type: 1 check keys (verifyFormula/regexp/maxLength/isEmptyRow/noRepeat/conditions), 2 FormulaConfig — `shortTextStitch` (falling back to `value`) MUST be a JSON OBJECT STRING whose `formula` key holds the expression, e.g. {\"shortTextStitch\":\"{\\\"formula\\\":\\\"{field}\\\",\\\"editorText\\\":\\\"{字段名}\\\"}\"}; a bare \"{field}\" string fails JSONUtil.isJson → getCalRuleExpression returns null → false 305003 dead-cycle; `formulaType:\"AGGREGATION\"` instead reads `aggregation`; a top-level `expression` is NEVER read (it is only a key INSIDE that nested JSON), 3 displayFormula, 4 requiredFormula, 5 readonlyCondition",
|
|
22
22
|
formulaReference: "类型2 公式引用按位置解析:裸 {字段}=**主记录**字段;带点 {子表code.字段}=**子表**字段(FormulaProcessor.constructSubExprParamsValueMap 要求点前等于子表 schema)。所以**主表公式**用裸 {字段}(带 {主表code.字段} 会按子表解析 → 值空/静默 null),**子表公式**(childRule:true)引用同级子字段必须带点 {子表code.字段}(裸引用被当主记录字段 → 值缺失 → 提交 50000)。工具在写前按子表已发布字段判定并拒绝裸引用(blocker datarule-formula-child-bare-reference),读回对存量子表公式加 formulaHint 提示复核。",
|
|
23
23
|
optionsEncoding: "the engine JSON-parses the `options` column and reads requiredFormula / readonlyCondition / displayFormula / verifyFormula / shortTextStitch (whose VALUE is itself a JSON string carrying `formula`); send options as a stringified object",
|
|
@@ -87,6 +87,7 @@ export const DATARULE_LANE_CONTRACT = Object.freeze({
|
|
|
87
87
|
"`dataRuleType` → options 键:3→displayFormula、4→requiredFormula(无条件必填=`\"true\"`)、5→readonlyCondition;1/2 的键与逐类型白名单见 `dataRuleType` 参数。8 EXTENSION out of scope.",
|
|
88
88
|
"`childRule:true` 仅用于已发布的子表列(propertyCode/propertyCodes 必须是子表列 code;主表字段省略)。子表列在发布面不可见时先用 field.create + field.publish 生成列,不要直接 POST datarule.create。",
|
|
89
89
|
"**⚠️ type3/4/5 两个读面**:门户**运行时**读**字段 options**(`field.create/update` 写),设计器**设计态** Set/Unset 读 **bizdatarule/list**(本行)。**type3/4/5 规则单独不会让门户表单控件变必填/只读**,符号式经 `historyOpt` 镜像还会让表单渲染崩溃——运行时条件请用中文操作符;表单条件优先走 `field.update`(自动配对本行)。",
|
|
90
|
+
"**type1(checkType1–4)默认仅门户提交执行;REST 数据面(data.submit/save)对非空值不跑**(空值仍校验)。`datarule.list` 读回为准,服务端强制用业务规则。",
|
|
90
91
|
"**类型3/4/5 条件串协议(平台 create 不校验,坏形状落库即雷,工具按此协议拒绝)**:`{字段code} 操作符 [值]`。操作符取 **bizdatarule 词表**(与字段 options 的表单交互引擎不同——那是符号式):**中文** 等于/不等于/大于/小于/大于等于/小于等于/包含/不包含/包含全部/不包含全部/包含任意一个/不包含任意一个/等于任意一个/属于/不属于/介于/为空/不为空,也接受符号 `==` `!=` `>` `<` `>=` `<=` `Contains` `IsEmpty` 等。为空/不为空**不带值**(`{field} 不为空`);其余带值(JSON 对象或标量)。多条件 ` && `、多组 ` || `。示例 type4:`options:{requiredFormula:\"{amount} 等于 {\\\"valueType\\\":\\\"specifyOption\\\",\\\"value\\\":\\\"A\\\"}\"}`。**字段绑定用 `propertyCodes`(数组)**,工具自动把 `options.propertyCodes` 也补上。",
|
|
91
92
|
"`options` is a JSON object sent to the wire as a JSON string(逐类型必读键见 `options` 参数面)。",
|
|
92
93
|
"类型2(计算/拼接):`options.shortTextStitch`(或 `value`)的值**必须是含 `formula` 的 JSON 对象字符串**,裸串会被工具拒绝(否则引擎返回 null → 误报 305003 死循环);顶层没有 `expression` 键——它只是该嵌套 JSON 内部的字段名(可照抄 `--example field-compute-rule`)。",
|
package/dist/lanes/datarule.js
CHANGED
|
@@ -15,6 +15,7 @@ import { DATARULE_LANE_CONTRACT, DATARULE_TYPE_OPTION_KEYS } from "./datarule-co
|
|
|
15
15
|
import { normalizeAggregationFormula } from "../field-families.js";
|
|
16
16
|
import { CONDITION_PROTOCOL_EXAMPLES, dataRuleOptionsShapeError } from "./datarule-protocol.js";
|
|
17
17
|
import { readModelRecord } from "../model-record.js";
|
|
18
|
+
import { partitionVersion } from "../version-partition.js";
|
|
18
19
|
const DATARULE_LANE = DATARULE_LANE_CONTRACT.lane;
|
|
19
20
|
const DATARULE_TOOLS = DATARULE_LANE_CONTRACT.tools;
|
|
20
21
|
const dataRuleTypeArg = z
|
|
@@ -195,9 +196,58 @@ function dataRuleExecutionWarning(checkType) {
|
|
|
195
196
|
if (checkType === 5)
|
|
196
197
|
return "重复校验 noRepeat 由服务端拦截,REST `data.submit` 亦会拒绝重复数据(errcode 800150006);properties 指定参与去重的字段。";
|
|
197
198
|
if (checkType === 1 || checkType === 2 || checkType === 3 || checkType === 4)
|
|
198
|
-
return "
|
|
199
|
+
return "该校验规则默认仅由门户前端提交校验执行;REST `data.submit` 不拦截违规数据(显式声明 validateHiddenProperties 的隐藏字段校验除外)。需要服务端拦截请改用业务规则(BIZ_ACTION/条件)。";
|
|
199
200
|
return "校验规则的执行面取决于 checkType;请在门户提交面验收,未提供 checkType 时不要把 REST 行为视为已验证。";
|
|
200
201
|
}
|
|
202
|
+
/** 版本证据 → hidden 校验执行面。2.1.x(含客户口径 8.8)执行;8.6/8.7/1.1 不执行。 */
|
|
203
|
+
export function dataRuleSubmitContext(session) {
|
|
204
|
+
const raw = session.detectedVersion() ?? session.rawSystemVersion() ?? "";
|
|
205
|
+
const partition = partitionVersion(raw);
|
|
206
|
+
const match = /^(\d+)\.(\d+)/u.exec(partition.matched);
|
|
207
|
+
const versionLabel = raw.trim().length > 0 ? raw.trim() : "版本证据不足";
|
|
208
|
+
const versionFamilyLabel = partition.family === "anchor-8.6"
|
|
209
|
+
? "8.6.x"
|
|
210
|
+
: partition.family === "legacy-8.0-8.5"
|
|
211
|
+
? "8.0–8.5(8.1.108 等)"
|
|
212
|
+
: partition.family === "legacy-1.1"
|
|
213
|
+
? "1.1.x(1.1.25 等)"
|
|
214
|
+
: partition.family === "ai-platform"
|
|
215
|
+
? /^8\.7\./u.test(partition.matched)
|
|
216
|
+
? "8.7.x(AI-Platform v1.1.x)"
|
|
217
|
+
: "2.1.x(AI-Platform 2.1+)"
|
|
218
|
+
: "版本族未识别";
|
|
219
|
+
const base = { versionLabel, versionFamilyLabel };
|
|
220
|
+
if (match === null)
|
|
221
|
+
return { hiddenSubmitCheck: "unknown", ...base };
|
|
222
|
+
const major = Number(match[1]);
|
|
223
|
+
const minor = Number(match[2]);
|
|
224
|
+
if (major === 2 && minor === 1)
|
|
225
|
+
return { hiddenSubmitCheck: "yes", ...base };
|
|
226
|
+
if (major === 8 && minor === 8)
|
|
227
|
+
return { hiddenSubmitCheck: "yes", ...base }; // 客户口径 8.8 = 2.1.x
|
|
228
|
+
if (major === 8 && minor >= 6 && minor <= 7)
|
|
229
|
+
return { hiddenSubmitCheck: "no", ...base };
|
|
230
|
+
if (major === 8 && minor <= 5)
|
|
231
|
+
return { hiddenSubmitCheck: "no", ...base };
|
|
232
|
+
if (major === 1 && minor === 1)
|
|
233
|
+
return { hiddenSubmitCheck: "no", ...base };
|
|
234
|
+
return { hiddenSubmitCheck: "unknown", ...base };
|
|
235
|
+
}
|
|
236
|
+
const PORTAL_NOTE_NON_HIDDEN = "该校验在门户表单提交时执行;CLI `data.submit`/`data.save`(REST runtime/form 路径)对**非空值**不执行(字段为空时平台仍会走空值校验,可能按必填类错误拒)——配置正确性以 datarule.list 读回为准,服务端强制请改用业务规则(BIZ_ACTION/条件)。";
|
|
237
|
+
/**
|
|
238
|
+
* `datarule.create` 的执行面 note。声明 `validateHiddenProperties` 时**只换
|
|
239
|
+
* 文案不抑制**:该键 2.1.5 独有,2.1.x 的 submit 面会跑,8.6.26/8.7 不跑。
|
|
240
|
+
*/
|
|
241
|
+
export function dataRuleRuntimeNote(options, context) {
|
|
242
|
+
const hidden = options.validateHiddenProperties;
|
|
243
|
+
if (!Array.isArray(hidden) || hidden.length === 0)
|
|
244
|
+
return PORTAL_NOTE_NON_HIDDEN;
|
|
245
|
+
if (context.hiddenSubmitCheck === "yes")
|
|
246
|
+
return `该规则声明 validateHiddenProperties:2.1.5+ 的 \`data.submit\` submit 面会执行这组隐藏字段校验(当前环境 ${context.versionLabel});其余条件仍以门户提交为准。配置正确性以 datarule.list 读回为准。`;
|
|
247
|
+
if (context.hiddenSubmitCheck === "no")
|
|
248
|
+
return `该规则声明 validateHiddenProperties,但该键是 2.1.5+ 独有:当前环境 ${context.versionLabel}(${context.versionFamilyLabel})的 \`data.submit\` 不执行它。配置正确性以 datarule.list 读回为准,验收走门户或 2.1.5+ 环境。`;
|
|
249
|
+
return `该规则声明 validateHiddenProperties:只有 2.1.5+(含客户口径 8.8)的 submit 面会执行;当前环境 ${context.versionLabel}(${context.versionFamilyLabel}),按未执行对待。配置正确性以 datarule.list 读回为准。`;
|
|
250
|
+
}
|
|
201
251
|
/**
|
|
202
252
|
* Fail closed when the options object cannot carry the key the engine reads
|
|
203
253
|
* for this type (RequiredDataRuleValidator / ReadOnlyValidator /
|
|
@@ -964,6 +1014,7 @@ export function registerDataRuleLane(tools) {
|
|
|
964
1014
|
? await runtimeWriteWithAppMapping(session, args.schemaCode, 305003, "datarule.create 类型2 CALCULATE 报死循环(305003,误判)", createRule)
|
|
965
1015
|
: await createRule();
|
|
966
1016
|
const rules = (await listDataRules(session, args.schemaCode, args.dataRuleType)).filter((row) => storedTargetCodes(row).some((code) => codes.includes(code)));
|
|
1017
|
+
const submitContext = dataRuleSubmitContext(session);
|
|
967
1018
|
return {
|
|
968
1019
|
performed: { errcode: performed.errcode },
|
|
969
1020
|
readback: {
|
|
@@ -977,7 +1028,13 @@ export function registerDataRuleLane(tools) {
|
|
|
977
1028
|
// 提交违规数据(-50 / 超阈值)errcode 0 放行、原值落库——校验在门户前端
|
|
978
1029
|
// 提交管线执行,REST 不拦。先告知执行面,省掉「先实测两轮才发现不生效」。
|
|
979
1030
|
...(args.dataRuleType === 1
|
|
980
|
-
? {
|
|
1031
|
+
? {
|
|
1032
|
+
executionWarning: dataRuleExecutionWarning(args.checkType),
|
|
1033
|
+
// P1(探针 H F3,复核 2026-11-27):声明 validateHiddenProperties
|
|
1034
|
+
// 的行**不抑制**提示——该键 2.1.5 独有,8.6.26/8.7 不执行;只按
|
|
1035
|
+
// 版本事实换文案。checkType5 是服务端重复校验,单独一类。
|
|
1036
|
+
...(args.checkType !== 5 ? { runtimeNote: dataRuleRuntimeNote(args.options, submitContext) } : {}),
|
|
1037
|
+
}
|
|
981
1038
|
: {}),
|
|
982
1039
|
...(() => { const w = dataRuleFormulaWarnings(args.dataRuleType, args.options); return w.length ? { lintWarnings: w } : {}; })(),
|
|
983
1040
|
},
|
|
@@ -5,12 +5,27 @@ import { governedRead } from "../read.js";
|
|
|
5
5
|
import { environmentWritable, requiresProductionConfirmation, versionEvidenceOf } from "../environment-policy.js";
|
|
6
6
|
import { versionFamilyNotice } from "../coverage.js";
|
|
7
7
|
import { flattenTreeRows } from "../support.js";
|
|
8
|
+
import { repairMojibakeText } from "../mojibake.js";
|
|
8
9
|
import { defineTool } from "../tool-types.js";
|
|
9
10
|
import { wireCall, wireRows } from "../wire.js";
|
|
10
11
|
import { ENVIRONMENT_LANE_CONTRACT } from "./environment-contract.js";
|
|
11
12
|
import { readProjectCard, writeProjectCard } from "../project-card.js";
|
|
12
13
|
const ENVIRONMENT_LANE = ENVIRONMENT_LANE_CONTRACT.lane;
|
|
13
14
|
const ENVIRONMENT_TOOLS = ENVIRONMENT_LANE_CONTRACT.tools;
|
|
15
|
+
/**
|
|
16
|
+
* F11(0.8.15):分组名展示面的保守还原。平台预置分组 `all` 在 DB 里是
|
|
17
|
+
* windows-1252 双编码(wire 原文即 `全部`,字节证据见 src/mojibake.ts),
|
|
18
|
+
* 修好时保留原文并标记,正常中文/ASCII 原样返回。缓存命中路径也走这里,
|
|
19
|
+
* 老卡里存的 mojibake 不会因升级后继续服务。
|
|
20
|
+
*/
|
|
21
|
+
function displayGroupName(rawName) {
|
|
22
|
+
if (typeof rawName !== "string")
|
|
23
|
+
return { name: rawName };
|
|
24
|
+
const repaired = repairMojibakeText(rawName);
|
|
25
|
+
return repaired.repaired
|
|
26
|
+
? { name: repaired.value, nameRaw: rawName, nameMojibake: true }
|
|
27
|
+
: { name: rawName };
|
|
28
|
+
}
|
|
14
29
|
/** r30f F2 — doctor / discover / fingerprint share one version-evidence face. */
|
|
15
30
|
function versionEvidenceFor(ctx, session) {
|
|
16
31
|
const detected = session.detectedVersion();
|
|
@@ -109,8 +124,20 @@ export function registerEnvironmentLane(tools) {
|
|
|
109
124
|
// r28b F16 / r29f F10:缓存是加速,不是第二套契约。键集必须与冷路径
|
|
110
125
|
// compact 同形;generatedAt / fromCacheHint 只做额外键。
|
|
111
126
|
const cachedExtra = cached;
|
|
112
|
-
const apps = Array.isArray(cached.applications)
|
|
113
|
-
|
|
127
|
+
const apps = Array.isArray(cached.applications)
|
|
128
|
+
? cached.applications.map((row) => {
|
|
129
|
+
const repaired = displayGroupName(row.groupName);
|
|
130
|
+
return repaired.nameMojibake === true
|
|
131
|
+
? { ...row, groupName: repaired.name, groupNameRaw: repaired.nameRaw, groupNameMojibake: true }
|
|
132
|
+
: row;
|
|
133
|
+
})
|
|
134
|
+
: [];
|
|
135
|
+
const groups = Array.isArray(cached.groups)
|
|
136
|
+
? cached.groups.map((row) => {
|
|
137
|
+
const repaired = displayGroupName(row.name);
|
|
138
|
+
return repaired.nameMojibake === true ? { ...row, ...repaired } : row;
|
|
139
|
+
})
|
|
140
|
+
: [];
|
|
114
141
|
const models = Array.isArray(cached.models)
|
|
115
142
|
? cached.models.map((row) => ({ schemaCode: row.code, name: row.name }))
|
|
116
143
|
: [];
|
|
@@ -188,7 +215,17 @@ export function registerEnvironmentLane(tools) {
|
|
|
188
215
|
// an informed decision.
|
|
189
216
|
const groups = wireRows((await wireCall(session, { path: ENDPOINTS.applicationGroupList, query: {} })).data).map((row) => {
|
|
190
217
|
const code = String(row.code ?? "");
|
|
191
|
-
|
|
218
|
+
// F11(0.8.15):平台预置分组 `all` 的名字在 DB 里是 windows-1252
|
|
219
|
+
// 双编码(wire 原文即 `全部`,见 src/mojibake.ts 的字节证据),
|
|
220
|
+
// 只在这一处展示面做保守还原;修好的行同时留 nameRaw + nameMojibake
|
|
221
|
+
// 让调用方知道 name 不是平台原文。正常中文/ASCII 原样不动。
|
|
222
|
+
const rawName = row.name ?? row.groupName ?? code;
|
|
223
|
+
return {
|
|
224
|
+
id: String(row.id ?? ""),
|
|
225
|
+
code,
|
|
226
|
+
...displayGroupName(rawName),
|
|
227
|
+
isFallback: code.toLowerCase() === "all",
|
|
228
|
+
};
|
|
192
229
|
});
|
|
193
230
|
const groupById = new Map(groups.map((group) => [group.id, group]));
|
|
194
231
|
const apps = appRows.map((row) => {
|
|
@@ -200,6 +237,9 @@ export function registerEnvironmentLane(tools) {
|
|
|
200
237
|
groupId: groupId ?? null,
|
|
201
238
|
groupCode: group?.code ?? null,
|
|
202
239
|
groupName: group?.name ?? null,
|
|
240
|
+
// 键集与缓存命中路径同形(该文件 :132-133 的既有约定):分组名被
|
|
241
|
+
// 保守还原时,应用行也带 nameRaw 语义的原文与标记。
|
|
242
|
+
...(group?.nameMojibake === true ? { groupNameRaw: group.nameRaw, groupNameMojibake: true } : {}),
|
|
203
243
|
portalHidden: group === undefined || group.isFallback === true,
|
|
204
244
|
};
|
|
205
245
|
});
|
|
@@ -311,7 +311,7 @@ export const FIELD_LANE_CONTRACT = Object.freeze({
|
|
|
311
311
|
}),
|
|
312
312
|
"field.get": Object.freeze({
|
|
313
313
|
scope: "create publish readback",
|
|
314
|
-
description: "
|
|
314
|
+
description: "单字段/多字段读(= field.list + code 或 fields[] 选择器,二者互斥;含 options/subSchema,子表原始 subSchema 传 full:true,与 field.list.full 同义)。字段行 options 含 mappings 时回执带 mappingRuntimeNote(REST 写不跑映射,配置正确性看 options.mappings)。",
|
|
315
315
|
}),
|
|
316
316
|
"field.create": Object.freeze({
|
|
317
317
|
scope: "create publish readback",
|