@stalfh233/omc-cli 0.8.37 → 0.8.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/field-add.js CHANGED
@@ -7,6 +7,10 @@
7
7
  *
8
8
  * 语义(与 model-scaffold 同族约定):
9
9
  * - **幂等**:字段已存在(duplicate)→ 记 skipped 继续(补建场景不该整批失败)。
10
+ * - **每个子调用独立 requestId**:命令级 requestId 只作 base,写/读子调用按
11
+ * `base:步骤:序号` 派生(见 `subRequestId`)。同 id 不同参数会被幂等门拒绝
12
+ * (argsDigestChanged),多字段必败;派生后多字段全成功,且同一 base 重跑时
13
+ * 已完成的子调用命中 replay(不重复建字段)。
10
14
  * - **不猜**:--fields 每项原样透传给 field.create(只补 schemaCode)。
11
15
  * - **失败不发布**:有真失败默认停在发布前(--force-publish 强发)。
12
16
  * - **列表增量**:listview.configure 默认合并语义(保留既有列/条件),只把新字段
@@ -20,6 +24,20 @@ import { writeEnvelope } from "./cli-output.js";
20
24
  import { assertSafeInputPath } from "./artifacts.js";
21
25
  import { readFileSync } from "node:fs";
22
26
  import { resolve } from "node:path";
27
+ /**
28
+ * 子调用 requestId 派生(w53 P1):`requestId` 是「(id, 参数指纹) 组合键」,
29
+ * 同一条命令里的预检与 N 个字段写、N 行演示数据**参数各不相同**,共用一个 id 会
30
+ * 让第 2 个子调用撞 `argsDigestChanged`(真机:2 字段 → created:1/failed:1 partial)。
31
+ *
32
+ * 派生规则:`${base}:${label}:${index}`(index 从 1 起;无序号步骤省略)。
33
+ * - **唯一**:同一命令内每个写/读子调用一个 id;
34
+ * - **稳定**:同一 base + 同一命令形状 → 同一派生 id,重跑时已完成的子调用命中
35
+ * 本地 replay(同 id 同指纹 → no-op),不会重复建字段;
36
+ * - **可读**:label 说明是哪一步,request.status 排障时一眼看出。
37
+ */
38
+ function subRequestId(base, label, index) {
39
+ return index === undefined ? `${base}:${label}` : `${base}:${label}:${index}`;
40
+ }
23
41
  /**
24
42
  * 模型级发布的爆炸半径:读出该模型草稿面里「不是本次要建的」字段。
25
43
  *
@@ -34,7 +52,8 @@ async function listOtherDraftFields(schemaCode, ownCodes, opts) {
34
52
  const callFieldList = async (published) => {
35
53
  const outcome = await runToolCall("field.list", {
36
54
  args: { schemaCode, published },
37
- requestId: opts.requestId,
55
+ // 读面不产生写产物,但同样按子调用派生,避免与写步骤共用 id 造成排障歧义。
56
+ requestId: subRequestId(opts.requestId, published ? "read:published" : "read:draft"),
38
57
  ...(opts.environment !== undefined ? { environment: opts.environment } : {}),
39
58
  ...(opts.context !== undefined ? { context: opts.context } : {}),
40
59
  print: () => undefined,
@@ -68,10 +87,14 @@ async function listOtherDraftFields(schemaCode, ownCodes, opts) {
68
87
  async function expandDictShorthand(fields, environment, contextForTest, request) {
69
88
  const problems = [];
70
89
  const expanded = [];
90
+ // 字典展开是只读链(dictionary.list + records ×N)。按子调用派生 id:虽是读面,
91
+ // 但同一条命令里多次用同一个 id 会让 request.status/journal 无法区分。
92
+ let readSeq = 0;
71
93
  const call = async (tool, args) => {
94
+ readSeq += 1;
72
95
  const outcome = await runToolCall(tool, {
73
96
  args,
74
- requestId: request,
97
+ requestId: subRequestId(request, `dict-read:${tool}`, readSeq),
75
98
  ...(environment !== undefined ? { environment } : {}),
76
99
  ...(contextForTest !== undefined ? { context: contextForTest } : {}),
77
100
  print: () => undefined,
@@ -145,8 +168,10 @@ export function validateFields(schemaCode, fields) {
145
168
  problems.push("--schema 必填");
146
169
  return problems;
147
170
  }
148
- export async function cmdFieldAdd(args, contextForTest) {
149
- const request = requestId();
171
+ export async function cmdFieldAdd(args, contextForTest, requestOverride) {
172
+ // `requestOverride` 是测试缝(不暴露 CLI flag):给同一 base 重放子调用,
173
+ // 验证「同一 base → 同一派生 id → 已完成子调用命中 replay」。
174
+ const request = requestOverride ?? requestId();
150
175
  const flag = (name) => argvValue(args, name);
151
176
  const schemaCode = flag("--schema") ?? flag("--schema-code") ?? flag("--code");
152
177
  const fieldsFile = flag("--fields-file");
@@ -249,10 +274,10 @@ export async function cmdFieldAdd(args, contextForTest) {
249
274
  };
250
275
  // 零 wire 形状预检(与 model-scaffold 同层防线):dry-run 走本地能力门。
251
276
  const preflightProblems = [];
252
- for (const field of fields) {
277
+ for (const [index, field] of fields.entries()) {
253
278
  const probe = await runToolCall("field.create", {
254
279
  args: { schemaCode, ...field },
255
- requestId: request,
280
+ requestId: subRequestId(request, "preflight:field-create", index + 1),
256
281
  dryRun: true,
257
282
  ...(environment !== undefined ? { environment } : {}),
258
283
  ...(contextForTest !== undefined ? { context: contextForTest } : {}),
@@ -315,10 +340,12 @@ export async function cmdFieldAdd(args, contextForTest) {
315
340
  }
316
341
  const steps = [];
317
342
  const lastSummaries = [];
318
- const call = async (tool, toolArgs) => {
343
+ // w53 P1:每个子调用一个派生 requestId(`subRequestId`)。此前共用命令级 id,
344
+ // 第二个 `field.create`(参数不同)被幂等门判成 argsDigestChanged → partial。
345
+ const call = async (tool, toolArgs, index) => {
319
346
  const outcome = await runToolCall(tool, {
320
347
  args: toolArgs,
321
- requestId: request,
348
+ requestId: subRequestId(request, tool, index),
322
349
  ...(environment !== undefined ? { environment } : {}),
323
350
  ...(contextForTest !== undefined ? { context: contextForTest } : {}),
324
351
  print: () => undefined,
@@ -332,8 +359,8 @@ export async function cmdFieldAdd(args, contextForTest) {
332
359
  // 1) 建字段:duplicate 记 skipped,其余失败继续跑完(一次看全)。
333
360
  const failedFields = [];
334
361
  const createdCodes = [];
335
- for (const field of fields) {
336
- const outcome = await call("field.create", { schemaCode, ...field });
362
+ for (const [index, field] of fields.entries()) {
363
+ const outcome = await call("field.create", { schemaCode, ...field }, index + 1);
337
364
  const message = String(outcome.result.message ?? "");
338
365
  if (outcome.ok) {
339
366
  steps.push({ step: "field.create", status: "ok", detail: { schemaCode, code: String(field.code) } });
@@ -410,7 +437,7 @@ export async function cmdFieldAdd(args, contextForTest) {
410
437
  }
411
438
  // 演示数据(--demo-rows):逐行 data.submit;失败记 failed 不阻断(行级独立)。
412
439
  for (const [index, row] of (demoRows ?? []).entries()) {
413
- const submitted = await call("data.submit", { schemaCode, formData: row });
440
+ const submitted = await call("data.submit", { schemaCode, formData: row }, index + 1);
414
441
  const readback = submitted.ok ? (submitted.result.readback ?? {}) : {};
415
442
  steps.push({
416
443
  step: "data.submit",
@@ -774,11 +774,14 @@ export function childSortKeyOutOfRangeWarnings(formData, childCodes, existingRec
774
774
  return warnings;
775
775
  }
776
776
  /**
777
- * Advisory only (issue #100): the platform mirrors every RADIO(12)/DROPDOWN(14)
778
- * value into a `<field>_key` companion column through
779
- * `OptionKeySupportImpl.getValueKeyMap` (8.6.26 :164-183). OMC does not write
780
- * the companion key; it only tells the caller when a hand-built payload has a
781
- * value without one (or a key that disagrees with the readable snapshot).
777
+ * Advisory only (issue #100): 8.6 mirrors every RADIO(12)/DROPDOWN(14) value into
778
+ * a `<field>_key` companion column through
779
+ * `OptionKeySupportImpl.getValueKeyMap` (8.6.26 :164-183). 2.1.5 live (w53,
780
+ * 2026-12-05) does NOT recompute that key on a Facade write — a supplied wrong
781
+ * key is persisted as-is (save readback + data.load both returned the wrong
782
+ * key). OMC never writes the companion key; it only tells the caller when a
783
+ * hand-built payload has a value without one (or a key that disagrees with the
784
+ * readable snapshot).
782
785
  */
783
786
  export function optionKeyWarnings(meta, formData, row = 1) {
784
787
  if (!meta)
@@ -819,7 +822,7 @@ export function optionKeyWarnings(meta, formData, row = 1) {
819
822
  suppliedKey: String(suppliedKey),
820
823
  expectedKey: suggested,
821
824
  optionSource: map.source,
822
- message: `字段 ${code} 的值 "${String(value)}" 对应的 ${keyCode} 应为 "${suggested}",实际传了 "${String(suppliedKey)}"(按${map.source === "snapshot" ? "字典快照" : "自定义选项"}推导);平台写面会重算该伴生键,OMC 仅提示`,
825
+ message: `字段 ${code} 的值 "${String(value)}" 与伴生键 ${keyCode} 不匹配:按${map.source === "snapshot" ? "字典快照" : "自定义选项"}推导应为 "${suggested}",实际传了 "${String(suppliedKey)}"。8.6 平台保存时可能重算该键;2.1.5 实测走 Facade 直接写入时不会自动重算,会保留传入的错误 key(2.1.7 待采样)。请显式写正确的 ${keyCode},不要依赖平台补偿。`,
823
826
  });
824
827
  }
825
828
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.8.37",
3
+ "version": "0.8.38",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "commander": "14.0.3",
61
- "omc-core": "0.8.37",
61
+ "omc-core": "0.8.38",
62
62
  "proper-lockfile": "4.1.2",
63
63
  "write-file-atomic": "6.0.0",
64
64
  "zod": "^3.23.8",
@@ -76,6 +76,6 @@
76
76
  "directory": "packages/omc-cli"
77
77
  },
78
78
  "optionalDependencies": {
79
- "@stalfh233/omc-fake-platform": "0.8.37"
79
+ "@stalfh233/omc-fake-platform": "0.8.38"
80
80
  }
81
81
  }