@stalfh233/omc-cli 0.8.6 → 0.8.8

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.
Files changed (40) hide show
  1. package/coverage/m1-coverage-manifest-v1.json +1 -0
  2. package/dist/approval-flow.js +49 -4
  3. package/dist/batch-call.js +21 -4
  4. package/dist/cli-stdout.js +1 -0
  5. package/dist/cli.js +84 -3
  6. package/dist/code-rules.js +35 -11
  7. package/dist/config-store.js +15 -1
  8. package/dist/endpoints.js +10 -0
  9. package/dist/form-layout.js +79 -0
  10. package/dist/form-support.js +111 -7
  11. package/dist/graph.js +38 -3
  12. package/dist/human-summary.js +19 -1
  13. package/dist/lanes/field-contract.js +5 -1
  14. package/dist/lanes/field-coverage.js +1 -0
  15. package/dist/lanes/field.js +20 -2
  16. package/dist/lanes/form-contract.js +1 -1
  17. package/dist/lanes/form.js +24 -2
  18. package/dist/lanes/list-view.js +104 -2
  19. package/dist/lanes/model-references.js +172 -0
  20. package/dist/lanes/model.js +206 -123
  21. package/dist/lanes/runtime-data-contract.js +4 -4
  22. package/dist/lanes/runtime-data.js +170 -7
  23. package/dist/lanes/workflow.js +213 -45
  24. package/dist/model-purge.js +106 -21
  25. package/dist/model-scaffold.js +52 -10
  26. package/dist/recipes/field.js +44 -1
  27. package/dist/recipes/form.js +33 -6
  28. package/dist/recipes/list-view.js +1 -1
  29. package/dist/reserved.js +28 -0
  30. package/dist/search-index.js +2 -0
  31. package/dist/tool-types.js +1 -0
  32. package/dist/write.js +12 -0
  33. package/package.json +3 -3
  34. package/skills/omc-business-configuration.md +6 -0
  35. package/skills/omc-capabilities.md +1 -1
  36. package/skills/omc-playbook.md +5 -0
  37. package/skills/omc-requirement-vocabulary.md +13 -0
  38. package/skills/omc-start-here.md +1 -1
  39. package/skills/omc-tool-selection.md +2 -0
  40. package/skills/omc-write-hazards.md +3 -0
@@ -28,6 +28,8 @@ import { writeEnvelope } from "./cli-output.js";
28
28
  import { ENDPOINTS } from "./endpoints.js";
29
29
  import { wireCall, wireRows } from "./wire.js";
30
30
  import { readModelRecord } from "./model-record.js";
31
+ import { inboundModelReferences, inboundReferenceRefusal } from "./lanes/model-references.js";
32
+ import { resolveModelTreeNode } from "./lanes/model.js";
31
33
  import { SessionManager } from "./session-manager.js";
32
34
  import { ConfigStore, defaultPaths } from "./config-store.js";
33
35
  async function sessionFor(environment) {
@@ -35,6 +37,29 @@ async function sessionFor(environment) {
35
37
  const sessions = new SessionManager(store);
36
38
  return sessions.session(environment);
37
39
  }
40
+ /**
41
+ * Map the inner refusal's executable steps to an ordered list of prerequisite
42
+ * targets, e.g. `["field.delete:items.repairRef", "field.publish:m",
43
+ * "model.delete:m"]`. The old purge receipt built this from
44
+ * `referencingModels` codes and produced `["m", "m"]` for a self-reference
45
+ * (the child column resolves back to the parent) — a list with no executable
46
+ * prerequisite and the target twice. Deriving it from the shared
47
+ * `deletionSteps` keeps the order and never repeats an entry.
48
+ */
49
+ export function purgeDeletionOrder(steps) {
50
+ const seen = new Set();
51
+ const order = [];
52
+ for (const step of steps) {
53
+ const schemaCode = String(step.args.schemaCode ?? "");
54
+ const code = typeof step.args.code === "string" ? step.args.code : "";
55
+ const target = step.tool === "field.delete" ? `field.delete:${schemaCode}.${code}` : `${step.tool}:${schemaCode}`;
56
+ if (seen.has(target))
57
+ continue;
58
+ seen.add(target);
59
+ order.push(target);
60
+ }
61
+ return order;
62
+ }
38
63
  /**
39
64
  * Read-only discovery: everything the purge would remove, in dependency order.
40
65
  * `session` is injectable so tests can plan against a fake platform; the CLI
@@ -146,6 +171,31 @@ export async function planPurge(options, injected) {
146
171
  const steps = [];
147
172
  if (instanceCount > 0)
148
173
  steps.push(options.purgeInstances ? `workflow.delete_instance ×${instanceCount}` : `⛔ ${instanceCount} 个流程实例(需 --purge-instances)`);
174
+ // Inbound-reference pre-scan: the SAME shared scan model.delete runs before
175
+ // physically_delete (src/lanes/model-references.ts). Read-only; a failure of
176
+ // the scan must not block the plan — the write path re-scans and refuses.
177
+ let referencePreview = {};
178
+ if (modelExists) {
179
+ try {
180
+ const resolved = await resolveModelTreeNode(session, options.schemaCode);
181
+ const references = resolved.treeRows.length > 0 ? await inboundModelReferences(session, [options.schemaCode], resolved.treeRows) : [];
182
+ if (references.length > 0) {
183
+ const refusal = inboundReferenceRefusal(options.schemaCode, references);
184
+ referencePreview = {
185
+ inboundReferences: references,
186
+ deletionSteps: refusal.deletionSteps,
187
+ deletionOrder: purgeDeletionOrder(refusal.deletionSteps),
188
+ nextCommand: refusal.nextCommand,
189
+ referenceNotice: `${options.schemaCode} 有入站引用(${refusal.referencingModels.map((model) => model.schemaCode).join("、")};` +
190
+ `子表列经 parentCode 解析回本模型时属于自引用)。--apply 的 model.delete 会零写入拒绝;先按 deletionSteps 逐条拆引用(nextCommand 是第一条),再重跑本命令。`,
191
+ };
192
+ steps.push(`⛔ 入站引用:先执行 deletionSteps(${refusal.deletionSteps[0]?.command ?? ""}),再删模型`);
193
+ }
194
+ }
195
+ catch {
196
+ // A scan error is reported by the write path's own gate; the plan stays useful.
197
+ }
198
+ }
149
199
  steps.push(`model.delete ${options.schemaCode}(级联带走:${[
150
200
  workflowCode ? `流程 ${workflowCode}` : undefined,
151
201
  listViews.length > 0 ? `${listViews.length} 个列表视图` : undefined,
@@ -173,6 +223,7 @@ export async function planPurge(options, injected) {
173
223
  instanceIds: [...instanceIds].slice(0, 50),
174
224
  steps,
175
225
  blockers,
226
+ ...referencePreview,
176
227
  };
177
228
  }
178
229
  /**
@@ -265,12 +316,13 @@ export async function cmdModelPurge(args) {
265
316
  return CLI_EXIT_CODES.internal;
266
317
  }
267
318
  if (!apply) {
319
+ const referenced = plan.inboundReferences !== undefined && plan.inboundReferences.length > 0;
268
320
  writeEnvelope(envelope("ok", {
269
- status: plan.blockers.length > 0 ? "blocked" : "dry-run",
321
+ status: plan.blockers.length > 0 || referenced ? "blocked" : "dry-run",
270
322
  ...plan,
271
323
  ...(plan.blockers.length > 0
272
324
  ? {}
273
- : { note: "dry-run 只列计划、不写。--apply 按上面的顺序执行;每步回读确认。" }),
325
+ : { note: `dry-run 只列计划、不写。--apply 按上面的顺序执行;每步回读确认。${referenced ? "入站引用已预扫(与 model.delete 同一份 gate):model.delete 会零写入拒绝,先按 deletionSteps 拆引用。" : ""}` }),
274
326
  }, request));
275
327
  return CLI_EXIT_CODES.ok;
276
328
  }
@@ -284,12 +336,28 @@ export async function cmdModelPurge(args) {
284
336
  }));
285
337
  return CLI_EXIT_CODES.policyRefused;
286
338
  }
287
- const steps = [];
288
339
  const session = await sessionFor(environment);
289
340
  const call = async (tool, toolArgs) => {
290
341
  const outcome = await runToolCall(tool, { args: toolArgs, requestId: request, ...(environment !== undefined ? { environment } : {}), print: () => undefined });
291
342
  return { ok: outcome.exitCode === 0, result: outcome.result };
292
343
  };
344
+ const execution = await executePurge(plan, session, call);
345
+ const result = execution.result;
346
+ const steps = Array.isArray(result.steps) ? result.steps : [];
347
+ const classified = classifyResult(execution.failed ? { ...result, requested: steps.length, succeeded: steps.filter((step) => step.status !== "failed").length } : result);
348
+ writeEnvelope(envelope(classified.status, result, request, classified.error));
349
+ return execution.failed ? 1 : 0;
350
+ }
351
+ /**
352
+ * Write phase: instances → `model.delete`, then build the receipt. Split from
353
+ * `cmdModelPurge` so the failure pass-through can be exercised without a live
354
+ * environment (the old code inline-built the receipt, so the F9 regression —
355
+ * dropping the inner `deletionSteps` and pointing `nextCommand` at the same
356
+ * command — had no test surface).
357
+ */
358
+ export async function executePurge(plan, session, call) {
359
+ const schemaCode = plan.schemaCode;
360
+ const steps = [];
293
361
  const record = (step, ok, detail) => {
294
362
  steps.push({ step, status: ok ? "ok" : "failed", ...(detail ? { detail } : {}) });
295
363
  };
@@ -316,6 +384,11 @@ export async function cmdModelPurge(args) {
316
384
  const unremovableInstances = instanceOutcome.unremovableInstances;
317
385
  // 2) the model — everything else cascades with it.
318
386
  let referrers = [];
387
+ // F9(0.8.8,探针 C):内层 model.delete 的零写入拒绝已带 inboundReferences /
388
+ // deletionSteps(可复制 command)。旧 purge 把它们压成 referrers 字符串,再用
389
+ // referrers 拼 deletionOrder/nextCommand:自引用(子表列 parentCode 解析回自身)
390
+ // 时得到 ["m","m"],nextCommand 只是重跑同一条命令——照做必再撞同一拒绝。
391
+ let deleteRefusal;
319
392
  if (!failed) {
320
393
  const outcome = await call("model.delete", { schemaCode });
321
394
  const readback = outcome.result.readback;
@@ -323,13 +396,39 @@ export async function cmdModelPurge(args) {
323
396
  referrers = Array.isArray(outcome.result.referencingModels)
324
397
  ? outcome.result.referencingModels.map((row) => String(row.schemaCode ?? "")).filter((code) => code.length > 0)
325
398
  : [];
399
+ const refusalMessage = typeof outcome.result.message === "string" && outcome.result.message.length > 0 ? outcome.result.message : refusalText(outcome.result);
326
400
  record(`model.delete:${schemaCode}`, outcome.ok || absent, outcome.ok || absent
327
401
  ? (readback ? { cascades: true, absent: readback.absent ?? null } : undefined)
328
- : { message: refusalText(outcome.result), ...(referrers.length > 0 ? { referencedBy: referrers } : {}) });
329
- if (!outcome.ok && !absent)
402
+ : { message: refusalMessage, ...(referrers.length > 0 ? { referencedBy: referrers } : {}) });
403
+ if (!outcome.ok && !absent) {
330
404
  failed = true;
405
+ const inboundReferences = Array.isArray(outcome.result.inboundReferences) ? outcome.result.inboundReferences : [];
406
+ const deletionSteps = Array.isArray(outcome.result.deletionSteps) ? outcome.result.deletionSteps : [];
407
+ if (inboundReferences.length > 0)
408
+ deleteRefusal = { inboundReferences, deletionSteps, message: refusalMessage };
409
+ }
331
410
  }
332
411
  const status = failed ? "partial" : "ok";
412
+ // Pass the inner refusal through verbatim; the purge-level receipt must not
413
+ // promise keys it dropped (F9: message named deletionSteps that were absent).
414
+ const failureFields = deleteRefusal !== undefined
415
+ ? {
416
+ nextAction: "execute-deletion-steps",
417
+ inboundReferences: deleteRefusal.inboundReferences,
418
+ deletionSteps: deleteRefusal.deletionSteps,
419
+ deletionOrder: purgeDeletionOrder(deleteRefusal.deletionSteps),
420
+ nextCommand: deleteRefusal.deletionSteps[0]?.command ?? `omc model-purge --code ${schemaCode}`,
421
+ ...(referrers.length > 0 ? { blockedBy: referrers } : {}),
422
+ message: `${schemaCode} 未删除(零写入拒绝,未启动平台删除任务)。${deleteRefusal.message} ` +
423
+ `按 deletionSteps 逐条执行(nextCommand 是第一条可复制命令);拆完引用后重跑 omc model-purge --code ${schemaCode} --apply(本命令会先删流程实例、再让 model.delete 级联)。`,
424
+ }
425
+ : {
426
+ nextAction: "fix-and-rerun",
427
+ ...(referrers.length > 0 ? { blockedBy: referrers } : {}),
428
+ message: referrers.length > 0
429
+ ? `${schemaCode} 仍被 ${referrers.join("、")} 的关联字段引用,模型不能删。先跑 omc model-purge --code ${schemaCode}(dry-run)拿 inboundReferences / deletionSteps,逐条拆引用后再 --apply。`
430
+ : "在失败的这一步停下(幂等,可修好后重跑同一条命令)。已成功的步骤不会重复破坏。",
431
+ };
333
432
  const result = {
334
433
  status,
335
434
  schemaCode,
@@ -339,19 +438,7 @@ export async function cmdModelPurge(args) {
339
438
  ...(unremovableInstances.length > 0 ? { unremovableInstances } : {}),
340
439
  steps,
341
440
  ...(failed
342
- ? {
343
- nextAction: "fix-and-rerun",
344
- ...(referrers.length > 0
345
- ? {
346
- blockedBy: referrers,
347
- deletionOrder: [...referrers, schemaCode],
348
- nextCommand: `omc model-purge --code ${referrers[0]} --purge-instances --apply`,
349
- }
350
- : {}),
351
- message: referrers.length > 0
352
- ? `${schemaCode} 仍被 ${referrers.join("、")} 的关联字段引用,模型不能删(平台 deleteFunctions 的异步拒绝已提前到调用时)。按 deletionOrder 先清引用方,再重跑本命令。`
353
- : "在失败的这一步停下(幂等,可修好后重跑同一条命令)。已成功的步骤不会重复破坏。",
354
- }
441
+ ? failureFields
355
442
  : unremovableInstances.length > 0
356
443
  ? {
357
444
  cleanupWarning: `${unremovableInstances.length} 条停滞实例无法通过平台 REST 删除(delete_instance 50000:业务对象已不存在,平台 NPE)。` +
@@ -365,8 +452,6 @@ export async function cmdModelPurge(args) {
365
452
  "**这就是 r12–r14 三次脏沙盒的根治**:实例先走,就不会留下指向空模板的待办。",
366
453
  }),
367
454
  };
368
- const classified = classifyResult(status === "partial" ? { ...result, requested: steps.length, succeeded: steps.filter((step) => step.status !== "failed").length } : result);
369
- writeEnvelope(envelope(classified.status, result, request, classified.error));
370
- return failed ? 1 : 0;
455
+ return { failed, result };
371
456
  }
372
457
  //# sourceMappingURL=model-purge.js.map
@@ -233,30 +233,47 @@ export async function cmdModelScaffold(args) {
233
233
  steps.push({ step: "model.create", status: created.ok ? "ok" : "skipped", ...(modelExists ? { detail: { reason: "already-present" } } : {}) });
234
234
  // 2) 字段:逐条,duplicate 记 skipped,其余失败继续跑完(一次看全)。
235
235
  const failedFields = [];
236
+ // F3(0.8.8,探针 C):回执计数必须解释得通。字段写入分两条路:
237
+ // - 顶层字段:一次 field.create 写一个字段;
238
+ // - CHILD_TABLE:平台在同一次 save 里把子表字段 **和声明的子列** 一起写进去
239
+ // (BizPropertyFacadeImpl.save:87-89:isSubTable() → ensureBizObjectSchema
240
+ // (property.getCode()).addProperty(subProperties)),因此 attach 成功之后
241
+ // 逐条 child:field.create 回 already-present 的子列,是「本次刚建出来」,
242
+ // 不是「本次开始前就在」。旧回执把两者都算 skipped(真机 13/6/6)。
243
+ let createdFieldCount = 0;
244
+ let alreadyPresentFieldCount = 0;
245
+ let childColumnsCreated = 0;
236
246
  // Only the PARENT publishes. A CHILD_TABLE's columns live under the parent's
237
247
  // schema (the platform answers 300004 数据模型不存在 for
238
248
  // bizproperty/publish on a child schema), and the parent's publish already
239
249
  // verifies them — r12's "checked 21/20/21" counts include child columns.
240
250
  const publishTargets = new Set([code]);
241
251
  const createFields = async (schemaCode, list, label) => {
252
+ const counts = { created: 0, alreadyPresent: 0, failed: 0 };
242
253
  for (const field of list) {
243
254
  const outcome = await call("field.create", scaffoldFieldArgs(schemaCode, field));
244
255
  const message = String(outcome.result.message ?? "");
245
256
  if (outcome.ok) {
257
+ counts.created += 1;
246
258
  steps.push({ step: `${label}:field.create`, status: "ok", detail: { schemaCode, code: field.code } });
247
259
  }
248
260
  else if (/已存在|duplicate/i.test(message)) {
261
+ counts.alreadyPresent += 1;
249
262
  steps.push({ step: `${label}:field.create`, status: "skipped", detail: { schemaCode, code: field.code, reason: "already-present" } });
250
263
  }
251
264
  else {
265
+ counts.failed += 1;
252
266
  const reason = refusalText(outcome.result);
253
267
  failedFields.push({ code: field.code, message: reason });
254
268
  steps.push({ step: `${label}:field.create`, status: "failed", detail: { schemaCode, code: field.code, message: reason } });
255
269
  }
256
270
  }
271
+ return counts;
257
272
  };
258
273
  const topLevel = fields.filter((field) => scaffoldChildrenOf(field).length === 0);
259
- await createFields(code, topLevel, "model");
274
+ const topCounts = await createFields(code, topLevel, "model");
275
+ createdFieldCount += topCounts.created;
276
+ alreadyPresentFieldCount += topCounts.alreadyPresent;
260
277
  // 3) 子表:先挂子表字段(CHILD_TABLE 建在父模型上),再往子表 schema 建子列。
261
278
  for (const child of fields.filter((field) => scaffoldChildrenOf(field).length > 0)) {
262
279
  const parentOutcome = await call("field.create", scaffoldFieldArgs(code, { ...child }));
@@ -267,6 +284,7 @@ export async function cmdModelScaffold(args) {
267
284
  steps.push({ step: "child:attach", status: "failed", detail: { parent: code, child: child.code, message: reason } });
268
285
  continue;
269
286
  }
287
+ const children = scaffoldChildrenOf(child);
270
288
  steps.push({
271
289
  step: "child:attach",
272
290
  status: parentOutcome.ok ? "ok" : "skipped",
@@ -276,10 +294,26 @@ export async function cmdModelScaffold(args) {
276
294
  detail: {
277
295
  parent: code,
278
296
  child: child.code,
279
- note: parentOutcome.ok ? "子表字段与子列在这一次 attach 中一起建立;随后的 child:field.create 返回 already-present 是正常的" : "子表已存在(含子列),跳过",
297
+ note: parentOutcome.ok
298
+ ? "子表字段与子列在这一次 attach 中一起建立(BizPropertyFacadeImpl.save 的 isSubTable 分支);随后的 child:field.create 返回 already-present 是正常的"
299
+ : "子表已存在(含子列),跳过",
280
300
  },
281
301
  });
282
- await createFields(child.code, scaffoldChildrenOf(child), "child");
302
+ const childCounts = await createFields(child.code, children, "child");
303
+ if (parentOutcome.ok) {
304
+ // The attach created the CHILD_TABLE field AND every declared column in one
305
+ // platform save; a follow-up already-present is THIS RUN's write, so it
306
+ // belongs to created (never to skipped). A column whose follow-up create
307
+ // really failed is counted as failed, not created.
308
+ const built = Math.max(0, children.length - childCounts.failed);
309
+ createdFieldCount += 1 + built;
310
+ childColumnsCreated += built;
311
+ }
312
+ else {
313
+ createdFieldCount += childCounts.created;
314
+ alreadyPresentFieldCount += 1 + childCounts.alreadyPresent;
315
+ childColumnsCreated += childCounts.created;
316
+ }
283
317
  }
284
318
  // 4) 发布字段:半成品不发布(比不发布更难查)。
285
319
  const publishFieldSteps = [];
@@ -327,21 +361,29 @@ export async function cmdModelScaffold(args) {
327
361
  }
328
362
  const failedSteps = steps.filter((step) => step.status === "failed");
329
363
  const status = failedSteps.length > 0 ? "partial" : "ok";
330
- const fieldCount = fields.reduce((sum, field) => sum + 1 + scaffoldChildrenOf(field).length, 0);
331
- // NOTE: renamed locally to unblock tsx (parallel agent redeclared `created`
332
- // in this same scope). Keep semantics identical.
333
- const fieldsCreated = steps.filter((step) => step.step.endsWith("field.create") && step.status === "ok").length;
364
+ const childColumnCount = fields.reduce((sum, field) => sum + scaffoldChildrenOf(field).length, 0);
365
+ // `fieldCount` 是历史键,语义是「最终业务字段总数」(顶层声明 + 子列);
366
+ // 落库计数改用显式键名(F3,0.8.8):created/skipped 旧键保留为别名,但取值
367
+ // 以「本次真的写入」为准,不再把 attach 一起建出的子列记成 skipped。
368
+ const fieldCount = fields.length + childColumnCount;
334
369
  const publishActions = publishFieldSteps.filter((step) => step.status === "ok").length;
335
370
  // r28g F5:旧键 publishedFields 实际是「发布动作次数/目标 schema 数」(常=1),
336
371
  // 与 fieldCount 量级不符。保留旧键作兼容别名,同时给 publishActions + 字段计数。
337
- const fieldsPublishedEstimate = publishingBlocked || fieldPublishFailed ? 0 : fieldsCreated;
372
+ const fieldsPublishedEstimate = publishingBlocked || fieldPublishFailed ? 0 : createdFieldCount;
338
373
  const result = {
339
374
  status,
340
375
  model: code,
341
376
  name,
342
377
  fieldCount,
343
- created: fieldsCreated,
344
- skipped: steps.filter((step) => step.step.endsWith("field.create") && step.status === "skipped").length,
378
+ declaredFieldCount: fields.length,
379
+ createdFieldCount,
380
+ alreadyPresentFieldCount,
381
+ childColumnCount,
382
+ childColumnsCreated,
383
+ failedFieldCount: failedFields.length,
384
+ countsNote: "declaredFieldCount = 本次 --fields 声明的顶层字段数;createdFieldCount = 本次真正新写入的业务字段数(子表 attach 一并建出的子列计入 created,不记 skipped);alreadyPresentFieldCount = 本次开始前就已存在的字段数;fieldCount = 最终业务字段总数(declaredFieldCount + childColumnCount)。旧键 created/skipped 分别是 createdFieldCount/alreadyPresentFieldCount 的别名。",
385
+ created: createdFieldCount,
386
+ skipped: alreadyPresentFieldCount,
345
387
  failed: failedFields.length,
346
388
  publishActions,
347
389
  publishedFields: publishActions,
@@ -228,6 +228,49 @@ const childTable = Object.freeze({
228
228
  ],
229
229
  requiresEnvironmentDerivedIds: false,
230
230
  });
231
+ /**
232
+ * 探针 C F1(0.8.8):子表列取主表字段的快照填充。
233
+ *
234
+ * 平台执行面(file:line 见交付报告):mappings 的 `{source,target}` 就是
235
+ * `WorkSheetPropertyMapping.linkageCode/assignmentCode`(2.1.5 :45-54)——
236
+ * source=关联目标(本例=父模型)字段,target=本模型(子表)字段;
237
+ * `WorkSheetMappingServiceImpl` 只在表单映射链里 `assignChildData`,CLI
238
+ * `data.save` 走的 `/api/runtime/form/save` 不调用 mappingList(探针 C F4)。
239
+ */
240
+ const childTableParentFieldFill = Object.freeze({
241
+ id: "child-map-fill",
242
+ title: "子表取主表",
243
+ aliases: ["取主表", "关联填充"],
244
+ status: "requires-prior-readback",
245
+ tool: "field.create",
246
+ args: {
247
+ environment,
248
+ schemaCode: "<model>_items",
249
+ code: "refParent",
250
+ name: "关联",
251
+ propertyType: "WORK_SHEET",
252
+ relativeCode: "<model>",
253
+ options: {
254
+ schemaCode: "<model>",
255
+ queryCode: "<model>",
256
+ displayField: "<父字段>",
257
+ mappings: [{ source: "<父字段>", target: "<快照列>" }],
258
+ },
259
+ },
260
+ preconditions: [
261
+ "子表 code 全局唯一;先建并发布快照标量列,再建关联列。",
262
+ "映射只在门户选值时回填:CLI data.save 不跑映射,API 写入须自带快照值。",
263
+ ],
264
+ conditionalRequirements: [
265
+ "关联列必须带 relativeCode(=options.schemaCode=主模型);source=主模型字段、target=本子表列,均裸 code。",
266
+ "关联列不能是 CHILD_TABLE/OCR/ELECTRONIC_SIGN/MULT_WORK_SHEET/RELEVANCE_DATA/FORMULA;field.publish 后 field.get 读回 options.mappings。",
267
+ ],
268
+ priorToolReferences: [],
269
+ dryRun: { supported: true, command: `omc call field.create --env ${environment} --dry-run --args '<args>'`, notes: "" },
270
+ expectedReadback: { readback: { fieldPresent: true }, next: ["field.publish", "field.get 读回映射"] },
271
+ refusalRecovery: [{ code: "relation-mapping-field-not-found", action: "source 用主模型字段、target 用本子表列,均裸 code" }],
272
+ requiresEnvironmentDerivedIds: true,
273
+ });
231
274
  const businessModelDropdown = Object.freeze({
232
275
  id: "business-model-dropdown",
233
276
  title: "用另一个模型的数据作下拉来源(businessModel)",
@@ -420,6 +463,6 @@ const externalLookupModel = Object.freeze({
420
463
  });
421
464
  export const FIELD_METADATA = Object.freeze({
422
465
  "field.update": Object.freeze({ recipes: [formConditionalRequired, formAlwaysReadonly, formConditionalReadonly], relatedTools: ["field.list", "field.publish", "form.draft", "form.publish"] }),
423
- "field.create": Object.freeze({ recipes: [fieldSerialNumber, numericTwoDecimals, numericPercent, dictionarySelection, dictionaryMultiSelection, childTable, businessModelDropdown, formulaAggregationCrossModel, formulaExpressionSameModel, externalLookupModel], relatedTools: ["dictionary.names", "dictionary.records", "discover_environment", "field.list", "field.publish", "form.draft", "configure_form", "form.publish"] }),
466
+ "field.create": Object.freeze({ recipes: [fieldSerialNumber, numericTwoDecimals, numericPercent, dictionarySelection, dictionaryMultiSelection, childTable, childTableParentFieldFill, businessModelDropdown, formulaAggregationCrossModel, formulaExpressionSameModel, externalLookupModel], relatedTools: ["dictionary.names", "dictionary.records", "discover_environment", "field.list", "field.publish", "form.draft", "configure_form", "form.publish"] }),
424
467
  });
425
468
  //# sourceMappingURL=field.js.map
@@ -19,6 +19,11 @@ const configureFormRecipe = Object.freeze({
19
19
  * 这里给一个**最小可抄**的两列 + 末行整宽样例;形状由 `form-layout.ts`
20
20
  * 的 validateFormLayout 把关(rows 必须是二维字符串数组、attrs 与 rows 覆盖一致、
21
21
  * 控件 options 必须是对象而不是 JSON 字符串)。
22
+ *
23
+ * 探针 B F1/F3(2.1.5 真机):控件 `type` 是**表单控件枚举**,与字段
24
+ * `propertyType` 不同源(关联单选 80 vs WORK_SHEET 9);且本配方只摆业务字段,
25
+ * 直接覆盖既有表单会丢掉系统控件、在 form.publish 撞 form-publish-degrade。
26
+ * 配方因此明确:既有表单先取 publishedAttributesJson 作基线。
22
27
  */
23
28
  const formDraftTwoColumn = Object.freeze({
24
29
  id: "two-column-layout",
@@ -36,25 +41,47 @@ const formDraftTwoColumn = Object.freeze({
36
41
  draftViewJson: '[[\"visitNo\",\"customer\"],[\"remark\"]]',
37
42
  draftAttributesJson: JSON.stringify({
38
43
  visitNo: { key: "visitNo", type: 1, options: { name: "拜访单号", span: 12 } },
39
- customer: { key: "customer", type: 9, options: { name: "客户", span: 12 } },
44
+ // customer 字段是 WORK_SHEET(propertyType 9) → 表单控件「关联单选」=80。
45
+ // 写成 9 是附件控件:平台照存、回读不报错,渲染时才坏。
46
+ customer: { key: "customer", type: 80, options: { name: "客户", span: 12 } },
40
47
  remark: { key: "remark", type: 1, options: { name: "备注", span: 24 } },
41
48
  }, null, 0),
42
49
  },
43
- preconditions: ["visitNo/customer/remark 三个字段已 field.publish(布局只能引用已发布字段)", "两段 JSON 都是**字符串**(tool 参数是 string,不是对象)"],
50
+ preconditions: [
51
+ "visitNo/customer/remark 三个字段已 field.publish(布局只能引用已发布字段)",
52
+ "两段 JSON 都是**字符串**(tool 参数是 string,不是对象)",
53
+ "**改既有表单**:先 `form.get full:true` 取 `publishedAttributesJson` 作基线(含 Title/Group/creater/createdTime/sequenceNo 系统控件),只改行分组与 span,不要把本配方的三字段最小布局直接盖上去。判据:`form.get full:true` 返回非空 publishedAttributesJson(或 published:true)→ 既有表单,受 form-publish-degrade 约束;无表单行 / publishedAttributesJson 为空或 \"{}\" → 新建表单,本配方可直接用。",
54
+ ],
44
55
  conditionalRequirements: [
45
56
  "**列数由行分组决定,不由 span 决定**:一行放几个 code 就是几列;span 只控制控件在行内的 24 栅格宽度,且必须与行分组自洽(两列 span:12+12,整宽 span:24)",
46
57
  "draftAttributesJson 的每个控件的 `options` 必须是**对象**,不能是 JSON 字符串(否则运行时写 options.name_i18n 抛错、整页空白)",
47
- "控件 type 与 field propertyType 数字同源(WORK_SHEET=9)",
58
+ "**控件 type 是表单控件枚举,不是字段 propertyType**:1=单行文本, 2=多行文本, 3=日期, 4=数值, 5=单选, 6=复选, 7=下拉, 8=逻辑, 80=关联单选, 81=关联多选, 201=子表 …;对应 propertyType 0/1/3/2/12/13/14/4/9/11/8。错枚举默认拒 `form-control-type-mismatch`(逃生 allowTypeMismatch:true)",
59
+ "本配方只摆 3 个业务字段,**没有系统控件**;对既有表单直接发布会被 form.publish 的降级门拒(form-publish-degrade),恢复见 refusalRecovery",
48
60
  "rows 与 attrs 的 code 集合必须一致,否则 `layout_coverage_mismatch`",
49
61
  "改列数就改行分组、重写 attrs 的 span —— 不要只改 span",
50
62
  ],
51
- priorToolReferences: [{ tool: "field.list", args: { environment, schemaCode: model, published: true }, purpose: "确认要摆的字段已发布" }],
52
- dryRun: { supported: true, command: `omc call form.draft --env ${environment} --dry-run --args '<recipe.args>'`, notes: "dry-run 会跑 validateFormLayout,形状不合规当场拒绝" },
53
- expectedReadback: { performed: { hasDraft: true }, readback: { next: ["form.publish", "form.get full:true 验布局"] } },
63
+ priorToolReferences: [
64
+ { tool: "field.list", args: { environment, schemaCode: model, published: true }, purpose: "确认要摆的字段已发布(同时给 propertyType,用于核对控件 type)" },
65
+ { tool: "form.get", args: { environment, schemaCode: model, full: true }, purpose: "改既有表单时取 publishedAttributesJson 作基线(保留系统控件)" },
66
+ ],
67
+ dryRun: { supported: true, command: `omc call form.draft --env ${environment} --dry-run --args '<recipe.args>'`, notes: "dry-run 会跑 validateFormLayout 与控件 type 交叉校验(读 field.list),形状/枚举不对当场拒绝" },
68
+ expectedReadback: {
69
+ performed: { hasDraft: true },
70
+ readback: { next: ["form.publish", "form.get full:true 验布局"] },
71
+ publishCheck: "form.publish 前核对草稿控件数 ≥ publishedAttributesJson 的控件数(系统控件不在本配方里,别直接覆盖既有表单)",
72
+ },
54
73
  refusalRecovery: [
55
74
  { code: "layout_coverage_mismatch", action: "把 draftViewJson 里出现的每个 code 都补进 draftAttributesJson(反之亦然)" },
56
75
  { code: "control_options_not_object", action: "把控件 options 从 JSON 字符串改成对象" },
76
+ {
77
+ code: "form-control-type-mismatch",
78
+ action: "按回执 mismatches 的 expectedType 改控件 type(关联单选=80、子表=201、单行文本=1…);或改既有表单时先 `form.get full:true` 取 publishedAttributesJson 作基线只改 rows/span,不要手拼控件 type。确属平台模板要求的特殊控件才传 allowTypeMismatch:true",
79
+ },
57
80
  { code: "form-field-not-published", action: "先 field.publish 再排布局" },
81
+ {
82
+ code: "form-publish-degrade",
83
+ action: "本配方只有业务字段,覆盖既有表单会丢系统控件。恢复:① `omc call form.get --args '{\"schemaCode\":\"<model>\",\"full\":true}'` 取 publishedAttributesJson;② 以它为基线只改 rows/span(保留 Title/Group/creater/createdTime/sequenceNo 与其它控件)重写草稿;③ 再 form.publish。纯新建表单(publishedAttributesJson 为空)不触发此门。不要把 allowDegrade:true 当默认解法",
84
+ },
58
85
  ...commonRecovery,
59
86
  ],
60
87
  requiresEnvironmentDerivedIds: false,
@@ -9,7 +9,7 @@ const listViewConfigure = Object.freeze({
9
9
  conditionalRequirements: [
10
10
  "**省略 `code` 即配置默认视图(code = schemaCode);不要先 listview.create——那会多出一个自定义视图。** 只有确实需要第二个视图时才 listview.create。案卷:r60a-F13 真机对齐 2026-11-13;r73 #6 真机对齐 2026-11-17;8.6.41 实测默认视图同样可 configure(改默认视图影响所有用户)。",
11
11
  "`fieldCodes` 只列业务字段,可给 propertyCode 或字段显示名;系统列由平台决定。未知引用被拒(listview-columns-unknown-field)。",
12
- "数值列 displayFormat 由字段 0 基 `options.scale` 推导(0=整数,1=1位,2=2位…;真机:scale 2 → displayFormat 3 = 两位小数);本工具会原地修正既有列的 displayFormat。",
12
+ "**`displayFormat` 是平台数值格式枚举,不是字段 `scale`**(scale 只决定小数位,currency/percent 会覆盖位数)。平台 `QueryRuntimeController.parseNumber`(8.6.26 :1830,case 1/2/3/11/12/23..26 小数、case 4/5/6/13/14/27..30 百分比、case 7/15/16/31..34 货币¥、case 8/17/18/35..38 美元、case 9/19/20/39..42 欧元;前端枚举同值:`RMB.percentile=7`、`ratio.percentile=6`,admin bundle 19497.069256cf.js)。枚举表:**1=0 位小数、2=1 位、3=2 位、11=3 位、12=4 位、23..26=5..8 位**(`1..n=小数位` 这一族;真机 scale 2 → displayFormat 3);**6=百分比(2 位)**、4/5/13/14/27..30 为百分比其它位数;**7=货币 ¥(2 位)**、15/16/31..34 为货币其它位数。金额列(NUMERICAL scale=2 + format=RMB.percentile)回读 7,不是 3。本工具会原地修正既有列的 displayFormat。",
13
13
  "**列汇总**:数值列 `sumType` wire 为整数——0=不统计/1=求和/2=平均/3=最小/4=最大/5=计数,写进 `presentation.columnsJson` 的列对象(8.6.26 反编译 SumType 实证)。",
14
14
  "`query/update` 自动 publish=TRUE——视图无草稿/发布两态,无需独立发布步骤。",
15
15
  ],
@@ -0,0 +1,28 @@
1
+ import { RESERVED_CODE_GROUPS } from "./code-rules.js";
2
+ /**
3
+ * F1(0.8.7 探针 B):保留字清单此前只在 `src/code-rules.ts` 里,报错只给
4
+ * `code_reserved` 分类,`omc help omc-write-hazards` 只有 SQL 关键字——探针
5
+ * 只能靠撞本地门发现 `owner` / `ownerName` 被拒。本函数是**同一张表**的只读
6
+ * 投影(`RESERVED_CODE_GROUPS` 由校验用的 Set 派生),零环境接触、零写入。
7
+ *
8
+ * 边界写清楚:这是本地 dry-lint 的清单,不是平台全量保留字清单;平台最终门
9
+ * 仍是 301014(属性 code 冲突)与 10033(SQL 关键字)。
10
+ */
11
+ export function reservedCodeReport() {
12
+ return {
13
+ status: "ok",
14
+ scope: "本地 code dry-lint(model.create / field.create / configure_model 使用同一张表);不是平台全量保留字清单",
15
+ rule: "业务模型 / 字段 code 不要使用下列编码;平台最终门:属性冲突 301014、SQL 关键字 10033",
16
+ total: RESERVED_CODE_GROUPS.reduce((sum, group) => sum + group.codes.length, 0),
17
+ groups: RESERVED_CODE_GROUPS.map((group) => ({
18
+ id: group.id,
19
+ title: group.title,
20
+ appliesTo: group.appliesTo,
21
+ count: group.codes.length,
22
+ codes: group.codes,
23
+ ...(group.note !== undefined ? { note: group.note } : {}),
24
+ })),
25
+ nextCommand: "omc help omc-write-hazards",
26
+ };
27
+ }
28
+ //# sourceMappingURL=reserved.js.map
@@ -28,6 +28,8 @@ const KEY_RULES = Object.freeze({
28
28
  workflowCode: { cls: "registry", source: "workflow.get_published → code" },
29
29
  sheetCode: { cls: "registry", source: "form.get / model.inspect → 默认表单槽位" },
30
30
  propertyCode: { cls: "registry", source: "field.list → fields[].code(名称匹配,可能歧义)" },
31
+ // 0.8.8(探针 C F1):子表关联列的 relativeCode = 关联目标模型 code(model.list 可查)。
32
+ relativeCode: { cls: "registry", source: "model.list → models[].schemaCode(关联目标模型)" },
31
33
  serviceCode: { cls: "registry", source: "service.list → serviceCode" },
32
34
  methodCode: { cls: "registry", source: "method.get / service.get → methodCode" },
33
35
  serviceCategoryId: { cls: "registry", source: "service.category.list → id(「全部」空 id 不可用)" },
@@ -103,6 +103,7 @@ const TOOL_INPUT_ALIASES = Object.freeze({
103
103
  "field.create": Object.freeze({ code: ["propertyCode"] }),
104
104
  "field.update": Object.freeze({ code: ["propertyCode"] }),
105
105
  "field.delete": Object.freeze({ code: ["propertyCode"] }),
106
+ "field.get": Object.freeze({ code: ["propertyCode"] }),
106
107
  // data.load's row id: callers habitually send `id` (bench67 wasted a round on
107
108
  // `bizObjectId: Required`). On this tool `id` unambiguously names the same
108
109
  // business object, so fill the canonical key rather than fail.
package/dist/write.js CHANGED
@@ -431,6 +431,18 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
431
431
  */
432
432
  export function deliveryStateFor(readback) {
433
433
  const record = readback !== null && typeof readback === "object" ? readback : undefined;
434
+ // The platform's async delete task itself failed (AppIntegrationFacadeImpl
435
+ // 8.6.26 :1348-1355: catch → message + TaskStatus.FAIL; read back through
436
+ // AppPackageController /delete/history). The record face still answers (the
437
+ // cascade aborted), so this must be checked FIRST — a FAIL can never be
438
+ // DELIVERED, and the platform text is the only real cause.
439
+ const rawDeleteTask = record?.deleteTask;
440
+ const deleteTask = rawDeleteTask !== null && typeof rawDeleteTask === "object" ? rawDeleteTask : undefined;
441
+ if (deleteTask?.taskStatus === "FAIL")
442
+ return {
443
+ deliveryState: "WRITE_UNVERIFIED",
444
+ readbackWarning: `未删除:平台删除任务失败(taskId=${String(deleteTask.taskId ?? "?")},平台原文:${String(deleteTask.message ?? "未返回 message")})——删除未完成,按平台原文拆引用/清残留后重试`,
445
+ };
434
446
  if (record?.present === false)
435
447
  return {
436
448
  deliveryState: "WRITE_UNVERIFIED",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.8.6",
3
+ "version": "0.8.8",
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.6",
61
+ "omc-core": "0.8.8",
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.6"
79
+ "@stalfh233/omc-fake-platform": "0.8.8"
80
80
  }
81
81
  }
@@ -345,4 +345,10 @@ BIZ_ACTION:
345
345
  配置读回 → CLI 运行触发 → workitem/data/service 读回 → 比较字段 → 清理测试数据
346
346
  ```
347
347
 
348
+ ### 清理顺序(数据 → 流程 → 模型)
349
+
350
+ - **数据 → 流程 → 模型**:先 `data.delete`;删流程前先清列表视图 `add` 绑定(首次 `workflow.publish` 自动绑;撞 `workflow-bound-to-listview`/303024 时用回执里的 `listviewBinding.unbindCommand`)。
351
+ - **视图随模型级联**:`listview.delete` 只用于替换视图;最后一条可见视图不可单删(2.1 回 306103)——要清视图就删模型。
352
+ - 完整恢复路径与 8.6/2.1 源码行号:`omc help omc-playbook --section cleanup`。
353
+
348
354
  浏览器不是常规验收步骤;只有用户报告 UI 回归时才做专项诊断。
@@ -87,7 +87,7 @@ only the section for the capability you need —
87
87
  - **单据号/自动编号(原生,勿二开)**:自建单据号字段是 `field.create` 的 `SHORT_TEXT + options.formPropertyType:100 + options.seqNoSetting` 分段构建器(CONSTANT/DELIMITER/DATE/PROPERTY/SEQNO/UID 段);DATAITEM 不是段类型,而是设计师 UI 的 resetDate 显示值。SEQNO 段 `resetDate:DAY/MONTH/YEAR` 原生按期重置——`describe field.create --example field-serial-number`。**不要落 SequenceService SPI 二开**(真机 r50 + 8.6.26 反编译证据,2026-11-10);编号生成时机=submit(`data.save` 不生成)。系统 `sequenceNo` 控件另为 objectId 双轨,勿混淆。
88
88
 
89
89
  - **能做哪些事**:字段族全链 create→publish→表单绑定;**CHILD_TABLE 子表**(子列是 schemaCode=父字段 code 上的普通字段);**计算字段**(默认用普通字段 + 「计算规则」,见下)。
90
- - **工具**:`field.list`、`field.create`、`field.update`、`field.publish`、`field.delete`
90
+ - **工具**:`field.get`(单字段读 = `field.list` + `code` 选择器)、`field.list`、`field.create`、`field.update`、`field.publish`、`field.delete`
91
91
  - **recipe**:
92
92
  - `omc describe field.create --example numeric-two-decimals`(数值 + scale)
93
93
  - `omc describe field.create --example dictionary-backed-single-select`
@@ -45,6 +45,11 @@ description: 一页纸业务场景步骤清单(采购申请 / 请假审批 /
45
45
  2. 取证:`omc call rulelog.search --args '{"schemaCode":"<模型>","bizObjectId":"<行id>"}'——触发/行/节点链一次问清。
46
46
 
47
47
 
48
+ ## 清理顺序(cleanup)
49
+
50
+ - 数据 → 流程 → 模型:先 `data.delete`;删流程前清列表 `add` 绑定(首次 publish 自动绑;303024 用 `listviewBinding.unbindCommand`)。
51
+ - 视图随模型级联(末条不可删);删模型看 `deleteTask.taskStatus`。
52
+
48
53
  ## 读法
49
54
 
50
55
  - 默认索引:`omc help omc-playbook`(看节摘要)
@@ -39,6 +39,19 @@ capability's coverage/tools/boundaries from `omc-capabilities`.
39
39
  | 集成、接口、服务、回调、对接外部系统 | B2 业务集成服务 (`service.register`);二开接口 = 扩展模块写 REST 接口 + RESTFUL 服务指向它;自定义协议适配器 SPI 非常规、不在支持面 |
40
40
  | 数据、提交、保存、删除、查记录 | M2 runtime data |
41
41
 
42
+ ## 子表关联列取主表字段(options.mappings 字段映射)
43
+
44
+ 需求原话常是「子表列指向主模型,把 `pb_repair.repairNo` 映射到 `pb_repair_items.repairNoSnapshot`」——这是**子表 schema 上的 WORK_SHEET 关联列 + `options.mappings`**,不是业务规则 `dataActions`。
45
+
46
+ 1. 先在子表 schema 建快照标量列(如 `repairNoSnapshot` SHORT_TEXT)并发布。
47
+ 2. 再建关联列,形状照抄配方 `omc describe field.create --example child-map-fill`:
48
+ `field.create {schemaCode:"<model>_items", code:"refParent", propertyType:"WORK_SHEET", relativeCode:"<model>", options:{schemaCode:"<model>", queryCode:"<model>", displayField:"<父字段>", mappings:[{source:"<父字段>",target:"<快照列>"}]}}`。
49
+ 3. `field.publish`(整模型一次)→ `field.get` 读回核对 `options.mappings`。
50
+
51
+ - **字段映射**的事实源是字段行 `options.mappings`(`source`=关联目标/父模型字段,`target`=本子表列,都是裸 code);改表单控件属性里的映射会被平台按字段重算覆盖。
52
+ - **关联填充只在门户选值时由表单运行时回填**:CLI `data.save`(`/api/runtime/form/save`)**不跑映射**,API 写入必须自己带快照列值,否则读回为空——这不是映射配置失败。
53
+ - 子表 code 是全局唯一子 schema;关联列必须带 `relativeCode`,且不能是 CHILD_TABLE / OCR / ELECTRONIC_SIGN / MULT_WORK_SHEET / RELEVANCE_DATA / FORMULA。
54
+
42
55
  ## 横切面 — landscape and boundaries
43
56
 
44
57
  Coverage status and boundaries for every capability (including 权限/子表/聚合/