@stalfh233/omc-cli 0.8.8 → 0.8.9

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.
@@ -11,7 +11,7 @@ import { QUERY_ACTION_TYPE } from "omc-core/list-view-wire";
11
11
  import { resolveModelTreeNode } from "./model.js";
12
12
  import { NUMERICAL_FORMAT_DECIMALS, SYSTEM_FIELD_CODES, canonicalNumericalFormat } from "../field-families.js";
13
13
  import { LIST_VIEW_LANE_CONTRACT } from "./list-view-contract.js";
14
- import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeConditionRow, decodeGantt, decodePresentation, decodeSortRow, diffTreeConditionKeys, LISTVIEW_TREE_CONDITION_KEYS, listViewActionArg, listViewButtonArg, listViewConditionArg, listViewGanttArg, listViewMultiTableHeaderArg, listViewOptionsArg, listViewPresentationArg, listViewQueryLayerArg, listViewSortArg, mergeActions, PLATFORM_DEFAULT_LIST_ACTIONS, normalizeActions, normalizeButtons, normalizeConditions, normalizeGantt, normalizePresentation, normalizeSorts, parseConditionOptions, presentationTypeArg, queryLayerSummary, readArray, resolveFieldRef, treeConditionKeysPresent, treeConditionValueEqual, buttonsRenderCompat, columnsRenderCompat, } from "./list-view-shapes.js";
14
+ import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeConditionRow, decodeGantt, decodePresentation, decodeSortRow, diffTreeConditionKeys, LISTVIEW_TREE_CONDITION_KEYS, listViewActionArg, listViewButtonArg, listViewConditionArg, listViewGanttArg, listViewMultiTableHeaderArg, listViewOptionsArg, listViewPresentationArg, listViewQueryLayerArg, listViewSortArg, mergeActions, PLATFORM_DEFAULT_LIST_ACTIONS, PLATFORM_INJECTED_READ_ACTIONS, normalizeActions, normalizeButtons, normalizeConditions, normalizeGantt, normalizePresentation, normalizeSorts, parseConditionOptions, presentationTypeArg, queryLayerSummary, readArray, resolveFieldRef, treeConditionKeysPresent, treeConditionValueEqual, buttonsRenderCompat, columnsRenderCompat, } from "./list-view-shapes.js";
15
15
  // Ticket 53: every shape (enum/zod/encode/decode/lint) lives once in
16
16
  // ./list-view-shapes.ts and is re-exported for existing import paths.
17
17
  export { assertListViewConfigureShape } from "./list-view-shapes.js";
@@ -1242,9 +1242,39 @@ export function registerListViewLane(tools) {
1242
1242
  }
1243
1243
  readback.columnsRenderCompat = columnsRenderCompat(readArray(afterModel, "queryColumns"));
1244
1244
  if (args.actions !== undefined) {
1245
- readback.actions = readArray(afterModel, "queryActions")
1245
+ const afterActions = readArray(afterModel, "queryActions")
1246
1246
  .map(decodeActionRow)
1247
1247
  .sort((a, b) => Number(a.sortKey ?? 0) - Number(b.sortKey ?? 0));
1248
+ readback.actions = afterActions;
1249
+ // F14(0.8.9 探针 D):actions:[] + replaceActions:true 之后 `actions` 仍
1250
+ // 列 6 条平台注入动作(BizQueryController.dealHistoryDataOfButton :482-575
1251
+ // 在 query/get 读面强制补齐 qr_code/batch_print/batch_update/
1252
+ // import_attachment/export_attachment/batch_submit),使用者会怀疑 replace
1253
+ // 没生效。区分三层:平台真值 actions 原样保留;本次被清掉的(旧有效集
1254
+ // 减去回读集)进 removedActionCodes;回读里由平台注入且不是调用方显式
1255
+ // 提交的 code 进 platformDefaultActions。只在权威全集替换时报告——
1256
+ // 默认 merge 本来就会保留既有动作,没有「是不是没生效」的疑问。
1257
+ if (args.replaceActions === true) {
1258
+ const afterCodes = new Set(afterActions.map((action) => String(action.actionCode ?? "")).filter(Boolean));
1259
+ const submittedCodes = new Set(args.actions.map((action) => String(action.actionCode ?? "")).filter(Boolean));
1260
+ const platformDefaultActions = afterActions
1261
+ .map((action) => String(action.actionCode ?? ""))
1262
+ .filter((code) => PLATFORM_INJECTED_READ_ACTIONS.includes(code) && !submittedCodes.has(code));
1263
+ const removedActionCodes = readArray(model, "queryActions")
1264
+ .map((action) => String(action.actionCode ?? ""))
1265
+ .filter((code) => code.length > 0 && !afterCodes.has(code) && !submittedCodes.has(code));
1266
+ if (removedActionCodes.length > 0)
1267
+ readback.removedActionCodes = [...new Set(removedActionCodes)];
1268
+ if (platformDefaultActions.length > 0)
1269
+ readback.platformDefaultActions = [...new Set(platformDefaultActions)];
1270
+ if (removedActionCodes.length > 0 || platformDefaultActions.length > 0) {
1271
+ readback.actionsNote =
1272
+ (removedActionCodes.length > 0 ? `本次移除 ${[...new Set(removedActionCodes)].join("、")};` : "") +
1273
+ (platformDefaultActions.length > 0
1274
+ ? `流程/自定义动作已清空;剩余为平台默认动作(${[...new Set(platformDefaultActions)].join("、")},query/get 注入,不是 replaceActions 未生效)。`
1275
+ : "流程/自定义动作已清空;剩余为平台默认动作。");
1276
+ }
1277
+ }
1248
1278
  }
1249
1279
  if (afterModel.queryPresentation && typeof afterModel.queryPresentation === "object") {
1250
1280
  readback.presentation = decodePresentation(afterModel.queryPresentation);
@@ -5,7 +5,7 @@ export { RUNTIME_DATA_WIRE, RUNTIME_QUERY_OPERATORS, ENGINE_OWNED_KEYS, SUBMIT_S
5
5
  import { RUNTIME_DATA_WIRE } from "omc-core/wire-facts";
6
6
  export function dataListDescription() {
7
7
  const wire = RUNTIME_DATA_WIRE;
8
- return `按简化过滤 DSL 查询业务对象(runtime/query/list);DSL 在 CLI 内翻译为平台 queryCondition(${wire.dslShape}),并按发布字段元数据为每个条件注入 propertyType(未知过滤字段将被拒绝,可用 rawCondition 逃生);响应行在 items[],业务字段在 items[].fields.<code>(不是 rows[],也不是 item 顶层——--jq 常用 items[].fields.sku);空模型返回空列表;列表只投影视图列:**已判定未投影的列会从 items[].fields 省略键**(items[].unprojected 点名;不是数据丢失——data.load 有值;显式选列在结果中全为 null 而发布字段元数据显示其存在时,readback 追加 projectionHint,先用 listview.configure 配置该模型的默认视图列或用 data.load 读单条权威值)。键缺席=字段不存在或该行已判定未投影(见 items[].unprojected);键在且值 null=真空值(未投影或真空值不再同形;nullSemantics 说明口径)。`;
8
+ return `按简化过滤 DSL 查询业务对象(runtime/query/list);DSL 在 CLI 内翻译为平台 queryCondition(${wire.dslShape}),并按发布字段元数据为每个条件注入 propertyType(未知过滤字段将被拒绝,可用 rawCondition 逃生;op 大小写不敏感);响应行在 items[],业务字段在 items[].fields.<code>(不是 rows[],也不是 item 顶层——--jq 常用 items[].fields.sku);空模型返回空列表;列表只投影视图列:**显式选列只能收窄、不能扩列**(视图外 code 进 columnsOutsideView,扩列用 data.load);**已判定未投影的列会从 items[].fields 省略键**(items[].unprojected 点名;不是数据丢失——data.load 有值;全 null 时 readback 追加 projectionHint,先 listview.configure 配置视图列或用 data.load 读单条)。键缺席=字段不存在或该行已判定未投影(见 items[].unprojected);键在且值 null=真空值(未投影或真空值不再同形;nullSemantics 说明口径)。`;
9
9
  }
10
10
  export function dataAggregateDescription() {
11
11
  return `临时计数与数值聚合(纯读)。count:runtime/query/list size:1 读 totalElements(服务端精确、不受 cap 影响;带 filter +1 field.list)。sum/avg/min/max:field 必填且已发布 propertyType=2(NUMERICAL);无 GET_LIST 改源时优先 /sum ALL_DATA(coverage.mode=server-aggregate,全量精确),否则/失败/键不符回退本地折叠(strategyFallback;size:200 翻页至 cap 1000,null 不进聚合、avg=sum/非 null 行数,nonNullCount=0→value:null)。complete 看 rowsScanned>=total,否则 missingCount+capNotice,绝不外推。groupBy 单列:count 值域可枚举(options/字典)→值域×count(V+3 wire),分桶并发窗口 4(限流退化 2,见 wire.concurrency),桶序稳定;按 count 降序取 topN(默认 10/上限 20),截断给 truncatedBuckets/bucketsTruncatedCount,null 单列 nullBucket;不可枚举或数值指标→本地扫描(coverage.mode=paged-local-scan/local-scan),数值桶 {key,count,nonNullCount,value} 按 value 降序、并列按 key,null 行进 nullBucket。filter.draftPolicy:count+groupBy 默认 includeDrafts:false 注入 sequenceStatus≠DRAFT;数值指标不默认排除;count 省略=平台默认(无条件含草稿、带条件排草稿);显式 false 强制排除。边界:临时问句用本工具;持久图表/看板用 report.chartdata,视图汇总列用 sumType,写时计算用 datarule type2。子表计数/求和用 child(主表 schemaCode + childSchemaCode/bizObjectId)。`;
@@ -353,6 +353,65 @@ function projectionHintWithMiss(hint, projectionMiss) {
353
353
  hint: `${hint?.hint ?? ""}${hint?.hint ? ";" : ""}${PROJECTION_MISS_HINT}`,
354
354
  };
355
355
  }
356
+ /** F5(w63,2026-11-26 真机 P1):columns 只收窄、不扩列;超出视图列的部分不可能有值。 */
357
+ export const DATA_LIST_COLUMNS_NARROWING_NOTE = "只能选视图列;扩列用 data.load 或加进视图。";
358
+ /**
359
+ * F5(w63,2026-11-26 真机 P1):`data.list` 的 `columns` 被调用方当成「任意
360
+ * 字段投影」用,但平台查询只取视图列——`display=false`(默认)时 SELECT 列集 =
361
+ * 视图 `queryColumns`(backend `BizObjectFacadeImpl.handleQueryColumn`:4155-4190,
362
+ * `display=true` 才 SELECT 全部属性;`getDisplayFields = completeSystemFields(
363
+ * columnList)`:2728-2729 只补系统列)。所以视图外的业务列在 wire 行里没有值,
364
+ * 本地裁剪再「保留」也补不回来。
365
+ *
366
+ * 判据(有证据才判,绝不拿 null 猜):
367
+ * - 请求的 code 不在**非空** `queryColumns` 清单里(listViewProjectionEvidence);
368
+ * - 或该 code 在整页 wire 行里键缺席(`projectionMiss`,与 0-F9 同源证据)。
369
+ *
370
+ * 空 `queryColumns` 不参与本判定:那种形状已由 `projectionHint` /
371
+ * `viewProjectionOnly`(全 null 业务列)覆盖,避免把「fake 默认无视图」误报成
372
+ * 「超列」。系统列由 completeSystemFields 恒投影,不判。
373
+ */
374
+ export function columnsOutsideViewOf(requested, viewColumnCodes, projectionMiss) {
375
+ if (requested === undefined || requested.length === 0)
376
+ return [];
377
+ const view = viewColumnCodes !== undefined && viewColumnCodes.length > 0 ? new Set(viewColumnCodes) : undefined;
378
+ const missed = projectionMiss.length > 0 ? new Set(projectionMiss) : undefined;
379
+ if (view === undefined && missed === undefined)
380
+ return [];
381
+ return [...new Set(requested)].filter((code) => {
382
+ if (code.length === 0 || RUNTIME_SYSTEM_FIELD_CODES.has(code) || code.endsWith("_") || code.endsWith("_key"))
383
+ return false;
384
+ if (missed?.has(code) === true)
385
+ return true;
386
+ return view !== undefined && !view.has(code);
387
+ });
388
+ }
389
+ /**
390
+ * F10(w63,2026-11-26 真机):DATE 字段读回固定 `YYYY-MM-DD HH:mm:ss`
391
+ * (0.8.8 只在 describe 写了,探针仍在回执里按 `options.format` 断言而踩)。
392
+ * 平台证据:
393
+ * - 表单 load/写回序列化用全局 ObjectMapper 的 `yyyy-MM-dd HH:mm:ss`
394
+ * (backend `ObjectMapperUtils.java:75`);
395
+ * - 列表行 DATE 额外按视图列 `displayFormat` 格式化,0/2 或无视图列时仍是
396
+ * `yyyy-MM-dd HH:mm:ss`(backend `QueryRuntimeController.parseDate`:2066-2140)。
397
+ * - 门户显示才读字段 `options.format`(frontend portal-app bundle
398
+ * `30079.c1617b14.js` 的 formatDisplayField → getDateShowText(value, options.format))。
399
+ *
400
+ * 只在**结果里真的出现 DATE 形状的日期串且元数据确认该 code 是 DATE** 时给一句;
401
+ * 元数据读失败零提示。候选按值形状先筛(避免每次读都多一跳 field.list)。
402
+ */
403
+ export const DATE_READBACK_NOTE = "DATE 字段读回固定 `YYYY-MM-DD HH:mm:ss`(00:00:00 只是日期的零点);`options.format` 只影响门户显示,不是 API 读回格式——按前 10 位(YYYY-MM-DD)比较即可。";
404
+ const DATE_READBACK_SHAPE = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}$/u;
405
+ function dateLikeCodes(fields) {
406
+ if (fields === null || fields === undefined || typeof fields !== "object")
407
+ return [];
408
+ return Object.entries(fields)
409
+ .filter(([, value]) => typeof value === "string" && DATE_READBACK_SHAPE.test(value))
410
+ .map(([code]) => code);
411
+ }
412
+ function hasDateCode(codes, typeByCode) {
413
+ return codes.some((code) => typeByCode.get(code) === FIELD_PROPERTY_TYPES.DATE);
414
+ }
356
415
  /**
357
416
  * 从 items 里找「null 业务列」(跨行全 null;任何一行有值就算已投影有数据),
358
417
  * 按视图列证据分类。无 null 业务列时返回 undefined(正常读取零噪音,与旧行为一致)。
@@ -599,6 +658,31 @@ function mappingRuntimeNoteFor(hits) {
599
658
  .join("、");
600
659
  return `REST 写不执行关联映射(options.mappings 只在门户选值时由表单运行时回填):${detail}${hits.length > shown.length ? ` 等 ${hits.length} 处` : ""};快照/映射目标字段需调用方在 formData 里自填,映射配置以 field.get 的 options 为准。`;
601
660
  }
661
+ const NAME_NOTE_VALUE_LIMIT = 40;
662
+ function shortReadbackValue(value) {
663
+ return value.length > NAME_NOTE_VALUE_LIMIT ? `${value.slice(0, NAME_NOTE_VALUE_LIMIT)}…` : value;
664
+ }
665
+ /**
666
+ * F8(w63,2026-11-26 真机):调用方在 `data.save.formData` 里显式给了 `name`,
667
+ * 读回却是「用户名+模型名+时间」——平台每次 insert/update 都用模型「数据标题」
668
+ * (bizSchema.summary)覆盖 name,且没有任何提示。
669
+ *
670
+ * 平台证据(8.6.26):
671
+ * - `BizObjectInsertModel.convertBizObjectOpItem:59-62` 与
672
+ * `BizObjectUpdateModel.convertBizObjectOpItem:65-68` 在构建 op item 时无条件
673
+ * 调 `BizObjectTitleSetter.setTitle(code, bizSchema.getSummary(), data)`;
674
+ * - `BizObjectTitleSetter.setTitle(code, summary, map)`(:115-117)把 summary
675
+ * 求值结果直接 put 进 `DefaultPropertyType.NAME`(name)。
676
+ * 所以「传了 name」不是可用的业务标识面;回执必须说清,而不是静默改值。
677
+ * 只在**显式传了 name 且与权威读回不同**时给一句(一致/未传 → 零提示)。
678
+ */
679
+ export function nameOverwrittenNoteOf(suppliedName, authoritativeName) {
680
+ if (typeof suppliedName !== "string" || suppliedName.trim() === "")
681
+ return undefined;
682
+ if (typeof authoritativeName !== "string" || authoritativeName === suppliedName)
683
+ return undefined;
684
+ return `平台按模型「数据标题」表达式自动覆盖了 name:传入“${shortReadbackValue(suppliedName)}”→读回“${shortReadbackValue(authoritativeName)}”;业务标识(单号/编码)请用自建字段,不要依赖 name。`;
685
+ }
602
686
  /**
603
687
  * data.list 的视图证据读取(query/get 失败/无视图 → undefined = 无证据)。
604
688
  * 拿到 queryColumns 数组才算可判定证据;视图对象在但 queryColumns 非数组 →
@@ -1680,11 +1764,11 @@ export function registerRuntimeDataLane(tools) {
1680
1764
  // `Expected object, received array`). An array is the caller's AND-list,
1681
1765
  // so accept it and treat it as `filters` rather than costing a retry
1682
1766
  // (dogfood R1 round17).
1683
- filter: z.union([z.record(z.string(), z.unknown()), z.array(z.record(z.string(), z.unknown()))]).optional().describe('one clause { op, field, value? } (or an array of clauses = AND); op 取值见过滤语义:eq/neq/gt/lt/gte/lte/like/notlike/in/notin/between/notbetween/isnull/isnotnull(camelCase 别名 equally valid: equals/notEquals/contains/isNull/isNotNull)。**like/contains 是子串包含(String.includes),不是前缀匹配,`%` / `_` 是字面量而非通配符**;按前缀分片请用 gte/lt 区间或更长的前缀+本地去重,别假设 like:"0%" 只命中 0 开头(取证案卷见 --example list-filter-equality)。field 须是**已发布**字段 code——写错时拒绝信封直接带 publishedFields/didYouMean,无需再查 field.list。计数问句:size:1 + 本参数 → 只读 total(服务端精确计数,不必拉行)'),
1767
+ filter: z.union([z.record(z.string(), z.unknown()), z.array(z.record(z.string(), z.unknown()))]).optional().describe('one clause {op,field,value?}(数组=AND); op 取值:eq/neq/gt/lt/gte/lte/like/notlike/in/notin/between/notbetween/isnull/isnotnull(camelCase 别名:equals/notEquals/contains/isNull/isNotNull;**op 大小写不敏感**,Eq/EQ/NotIn 直接可用)。**like/contains 是子串包含(String.includes),不是前缀匹配,`%` / `_` 是字面量而非通配符**;前缀分片用 gte/lt 区间或更长前缀+本地去重,别假设 like:"0%" 只命中 0 开头(取证案卷见 --example list-filter-equality)。field 须是**已发布**字段 code——写错时拒绝信封带 publishedFields/didYouMean,无需再查 field.list。计数问句:size:1 + 本参数 → 只读 total(服务端精确)'),
1684
1768
  filters: z.array(z.record(z.string(), z.unknown())).optional().describe("clauses combined with AND; a malformed clause is refused with blocker invalid-filter-DSL"),
1685
1769
  filterGroup: z.record(z.string(), z.unknown()).optional().describe('nested group { op:"and"|"or", clauses:[clause|group] }'),
1686
1770
  rawCondition: z.unknown().optional(),
1687
- displayFields: z.array(z.string().min(1)).optional().describe("列投影(**本地裁剪**:平台 query/list 不认 displayFields,body 不发送该键;返回全列后本地只留这些 code);与 columns / fields 同义"),
1771
+ displayFields: z.array(z.string().min(1)).optional().describe("列投影(**本地裁剪**:平台只 SELECT 视图 queryColumns,不认 displayFields;**只能收窄不能扩列**,视图外 code 进 columnsOutsideView);与 columns / fields 同义"),
1688
1772
  columns: z.array(z.string().min(1)).optional().describe("列投影别名(=displayFields)"),
1689
1773
  // r29b F9: data.load/save/update 都叫 fields;list 面原先只有 displayFields/columns。
1690
1774
  fields: z.array(z.string().min(1)).optional().describe("列投影别名(=displayFields;与 data.load/data.save/data.update 的 fields 同语义)"),
@@ -2076,8 +2160,9 @@ export function registerRuntimeDataLane(tools) {
2076
2160
  const preview = dataListItemPreview(items);
2077
2161
  const nullProjection = items.some((item) => Object.values(item.fields).some((value) => value === null));
2078
2162
  // F2(retro 24):出现 null 业务列才读视图证据(正常读取零额外 wire);
2079
- // 证据链见 projectionHintFace 的源码注释。
2080
- const viewEvidence = nullProjection ? await listViewProjectionEvidence(session, args.schemaCode, args.queryCode ?? args.schemaCode) : undefined;
2163
+ // 证据链见 projectionHintFace 的源码注释。F5(w63):显式选列时必须读
2164
+ // 视图列证据才能判「超列」,一笔额外 query/get 只付在显式投影的读上。
2165
+ const viewEvidence = nullProjection || fields !== undefined ? await listViewProjectionEvidence(session, args.schemaCode, args.queryCode ?? args.schemaCode) : undefined;
2081
2166
  const projectionHintAll = projectionHintWithMiss(projectionHintFace(items, viewEvidence), projectionMissAll);
2082
2167
  const columnsNotProjected = await relationNotProjectedOf(items, projectionMissAll, viewEvidence?.viewColumnCodes);
2083
2168
  const itemsWithProjection = attachItemUnprojected(items, projectionMissAll, viewEvidence?.viewColumnCodes);
@@ -2085,6 +2170,20 @@ export function registerRuntimeDataLane(tools) {
2085
2170
  // 无证据的 null(真空值)保留。诊断都已用带 null 的 items 算完再省略。
2086
2171
  const itemsFinal = omitUnprojectedFields(itemsWithProjection);
2087
2172
  const anyNullField = itemsFinal.some((item) => Object.values(item.fields).some((value) => value === null));
2173
+ // F5(w63,P1):columns 只能收窄视图列;视图外的 code 点名。
2174
+ const columnsOutsideView = columnsOutsideViewOf(fields, viewEvidence?.viewColumnCodes, projectionMissAll);
2175
+ // F10(w63):结果里真有 DATE 形状的值时才读一次元数据确认类型。
2176
+ const dateCandidates = [...new Set(itemsFinal.flatMap((item) => dateLikeCodes(item.fields)))];
2177
+ let dateReadbackNote;
2178
+ if (dateCandidates.length > 0) {
2179
+ try {
2180
+ if (hasDateCode(dateCandidates, await publishedTypeByCode()))
2181
+ dateReadbackNote = DATE_READBACK_NOTE;
2182
+ }
2183
+ catch {
2184
+ // 元数据读失败 → 零提示(读面诊断不阻断读取)
2185
+ }
2186
+ }
2088
2187
  return {
2089
2188
  schemaCode: args.schemaCode,
2090
2189
  ...application,
@@ -2135,6 +2234,8 @@ export function registerRuntimeDataLane(tools) {
2135
2234
  ...(anyNullField ? { nullSemantics: DATA_LIST_NULL_SEMANTICS } : {}),
2136
2235
  ...(projectionMissAll.length > 0 ? { projectionMiss: projectionMissAll } : {}),
2137
2236
  ...(columnsNotProjected.length > 0 ? { columnsNotProjected } : {}),
2237
+ ...(columnsOutsideView.length > 0 ? { columnsOutsideView, columnsNarrowingOnly: true, columnsNote: DATA_LIST_COLUMNS_NARROWING_NOTE } : {}),
2238
+ ...(dateReadbackNote !== undefined ? { dateReadbackNote } : {}),
2138
2239
  items: itemsFinal,
2139
2240
  };
2140
2241
  }
@@ -2271,14 +2372,29 @@ export function registerRuntimeDataLane(tools) {
2271
2372
  }).length;
2272
2373
  // F2(retro 24):出现 null 业务列才读视图证据;证据链与语义见
2273
2374
  // projectionHintFace / listViewProjectionEvidence 的源码注释。
2375
+ // F5(w63):显式选列时必须读视图列证据才能判「超列」。
2274
2376
  const hasNullValue = items.some((item) => Object.values(item.fields).some((value) => value === null));
2275
- const viewEvidence = hasNullValue ? await listViewProjectionEvidence(session, args.schemaCode, args.queryCode ?? args.schemaCode) : undefined;
2377
+ const viewEvidence = hasNullValue || fields !== undefined ? await listViewProjectionEvidence(session, args.schemaCode, args.queryCode ?? args.schemaCode) : undefined;
2276
2378
  const projectionHintPaged = projectionHintWithMiss(projectionHintFace(items, viewEvidence), projectionMissPaged);
2277
2379
  const columnsNotProjected = await relationNotProjectedOf(items, projectionMissPaged, viewEvidence?.viewColumnCodes);
2278
2380
  const itemsWithProjection = attachItemUnprojected(items, projectionMissPaged, viewEvidence?.viewColumnCodes);
2279
2381
  // F5(w53):已判定未投影的列从 fields 省略键;无证据的 null 保留。
2280
2382
  const itemsFinal = omitUnprojectedFields(itemsWithProjection);
2281
2383
  const anyNullField = itemsFinal.some((item) => Object.values(item.fields).some((value) => value === null));
2384
+ // F5(w63,P1):columns 只能收窄视图列;视图外的 code 点名。
2385
+ const columnsOutsideView = columnsOutsideViewOf(fields, viewEvidence?.viewColumnCodes, projectionMissPaged);
2386
+ // F10(w63):结果里真有 DATE 形状的值时才读一次元数据确认类型。
2387
+ const dateCandidates = [...new Set(itemsFinal.flatMap((item) => dateLikeCodes(item.fields)))];
2388
+ let dateReadbackNote;
2389
+ if (dateCandidates.length > 0) {
2390
+ try {
2391
+ if (hasDateCode(dateCandidates, await publishedTypeByCode()))
2392
+ dateReadbackNote = DATE_READBACK_NOTE;
2393
+ }
2394
+ catch {
2395
+ // 元数据读失败 → 零提示(读面诊断不阻断读取)
2396
+ }
2397
+ }
2282
2398
  // F6 工单 05b:只有本页行真的内联了子表数组才给一句(否则零字节);
2283
2399
  // 取第一条命中行,命令里的 schemaCode/childSchemaCode/bizObjectId 都是真值。
2284
2400
  const inlineChild = itemsFinal
@@ -2321,6 +2437,8 @@ export function registerRuntimeDataLane(tools) {
2321
2437
  ...(anyNullField ? { nullSemantics: DATA_LIST_NULL_SEMANTICS } : {}),
2322
2438
  ...(projectionMissPaged.length > 0 ? { projectionMiss: projectionMissPaged } : {}),
2323
2439
  ...(columnsNotProjected.length > 0 ? { columnsNotProjected } : {}),
2440
+ ...(columnsOutsideView.length > 0 ? { columnsOutsideView, columnsNarrowingOnly: true, columnsNote: DATA_LIST_COLUMNS_NARROWING_NOTE } : {}),
2441
+ ...(dateReadbackNote !== undefined ? { dateReadbackNote } : {}),
2324
2442
  totalPages,
2325
2443
  itemsCount: items.length,
2326
2444
  itemsReturned: items.length,
@@ -3076,7 +3194,24 @@ export function registerRuntimeDataLane(tools) {
3076
3194
  const inlineChild = data && typeof data === "object" && !Array.isArray(data)
3077
3195
  ? inlineChildRowsOf(data, args.bizObjectId)
3078
3196
  : undefined;
3079
- return { schemaCode: args.schemaCode, bizObjectId: args.bizObjectId, exists: data != null, ...(missingFields ? { missingFields, availableFields: data && typeof data === "object" ? Object.keys(data) : [] } : {}), ...(includeSchema ? {} : { schemaCached: true }), ...(inlineChild !== undefined ? { childRowsHint: childRowsAggregateHint(inlineChild, args.schemaCode, "本记录内联了子表行") } : {}), data };
3197
+ // F10(w63):结果里真有 DATE 形状的值时才读一次字段元数据确认类型,
3198
+ // 确认是 DATE 才给一句(元数据读失败零提示,绝不阻断读取)。
3199
+ let dateReadbackNote;
3200
+ if (data && typeof data === "object" && !Array.isArray(data)) {
3201
+ const dateCandidates = dateLikeCodes(data);
3202
+ if (dateCandidates.length > 0) {
3203
+ try {
3204
+ const meta = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: args.schemaCode, isPublish: "true" } })).data);
3205
+ const typeByCode = new Map(meta.map((row) => [String(row.code ?? row.propertyCode ?? ""), Number(row.propertyType ?? row.type)]));
3206
+ if (hasDateCode(dateCandidates, typeByCode))
3207
+ dateReadbackNote = DATE_READBACK_NOTE;
3208
+ }
3209
+ catch {
3210
+ // 元数据读失败 → 零提示
3211
+ }
3212
+ }
3213
+ }
3214
+ return { schemaCode: args.schemaCode, bizObjectId: args.bizObjectId, exists: data != null, ...(missingFields ? { missingFields, availableFields: data && typeof data === "object" ? Object.keys(data) : [] } : {}), ...(includeSchema ? {} : { schemaCached: true }), ...(inlineChild !== undefined ? { childRowsHint: childRowsAggregateHint(inlineChild, args.schemaCode, "本记录内联了子表行") } : {}), ...(dateReadbackNote !== undefined ? { dateReadbackNote } : {}), data };
3080
3215
  }, { full: args.full === true, target: `data.load:${args.schemaCode}:${args.bizObjectId}` });
3081
3216
  },
3082
3217
  }));
@@ -3228,12 +3363,15 @@ export function registerRuntimeDataLane(tools) {
3228
3363
  let sequenceStatus = null;
3229
3364
  readbackData = (await wireCall(session, { path: ENDPOINTS.runtimeFormLoad, query: { schemaCode: args.schemaCode, sheetCode, objectId: returnedId } })).data;
3230
3365
  sequenceStatus = extractSequenceStatus((readbackData ?? {}));
3366
+ const workflowReadbackRecord = normalizeLoadedRecord((readbackData ?? {}));
3367
+ // F8(w63):显式传了 name 却被平台「数据标题」覆盖 → 回执点名(不改写入行为)。
3368
+ const workflowNameNote = nameOverwrittenNoteOf(rawSaveData.name, workflowReadbackRecord?.name);
3231
3369
  // F4(w53):本次 formData 真带子表数组时才读子表字段元数据;无数组/读不到
3232
3370
  // 元数据 → 零提示(读失败不阻断写)。
3233
3371
  const mappingRuntimeNote = mappingRuntimeNoteFor(await childTableMappingHits(session, formData, prepared.childCodes));
3234
3372
  return {
3235
3373
  performed: { errcode: performed.errcode, ...application, bizObjectId: returnedId, workflowInstanceId, workItemId, workItemSource, sheetCode, resolvedFrom, formType: "save-draft-workflow" },
3236
- readback: { ...application, ...writeDiagnostics, ...(mappingRuntimeNote !== undefined ? { mappingRuntimeNote } : {}), authoritative: projectReadbackRecord(normalizeLoadedRecord((readbackData ?? {})), args), sequenceStatus, expectedSequenceStatus: "DRAFT" },
3374
+ readback: { ...application, ...writeDiagnostics, ...(mappingRuntimeNote !== undefined ? { mappingRuntimeNote } : {}), ...(workflowNameNote !== undefined ? { nameOverwrittenNote: workflowNameNote } : {}), authoritative: projectReadbackRecord(workflowReadbackRecord, args), sequenceStatus, expectedSequenceStatus: "DRAFT" },
3237
3375
  };
3238
3376
  }
3239
3377
  // 券商 issue 1.3(cpdocs 2026-10-27):带 formData.id 的 save 是更新语义;
@@ -3280,6 +3418,8 @@ export function registerRuntimeDataLane(tools) {
3280
3418
  // row. Saying so on every plain-save readback prevents the
3281
3419
  // "rule didn't fire" misdiagnosis.
3282
3420
  const savedRecord = normalizeLoadedRecord((readbackData ?? {}));
3421
+ // F8(w63):显式传了 name 却被平台「数据标题」覆盖 → 回执点名(不改写入行为)。
3422
+ const nameOverwrittenNote = nameOverwrittenNoteOf(rawSaveData.name, savedRecord?.name);
3283
3423
  const savedEmptyFields = readbackEmptyFields(formData, savedRecord);
3284
3424
  const dataWarnings = await runtimeDataWarnings(session, args.schemaCode, sheetCode, formData, 1);
3285
3425
  const publishedWorkflow = await resolvePublishedWorkflowCode(session, args.schemaCode);
@@ -3293,6 +3433,7 @@ export function registerRuntimeDataLane(tools) {
3293
3433
  ...application,
3294
3434
  ...writeDiagnostics,
3295
3435
  ...(mappingRuntimeNote !== undefined ? { mappingRuntimeNote } : {}),
3436
+ ...(nameOverwrittenNote !== undefined ? { nameOverwrittenNote } : {}),
3296
3437
  authoritative: projectReadbackRecord(savedRecord, args),
3297
3438
  ...(savedEmptyFields.length > 0 ? { readbackWarning: readbackWarningFor(savedEmptyFields, "data.save") } : {}),
3298
3439
  ...(dataWarnings.length > 0 ? { warnings: dataWarnings } : {}),
@@ -32,6 +32,23 @@ import { inboundModelReferences, inboundReferenceRefusal } from "./lanes/model-r
32
32
  import { resolveModelTreeNode } from "./lanes/model.js";
33
33
  import { SessionManager } from "./session-manager.js";
34
34
  import { ConfigStore, defaultPaths } from "./config-store.js";
35
+ /** The ONLY step kinds the purge may execute on its own. `model.delete` is never one. */
36
+ const UNBIND_STEP_TOOLS = new Set(["field.delete", "field.publish"]);
37
+ /**
38
+ * Restrict a `deletionSteps` list to the unlink-only steps. Safety invariant:
39
+ * the purge never executes arbitrary commands from the refusal — only the two
40
+ * tools that remove a reference column and republish its owner.
41
+ */
42
+ export function unbindDeletionSteps(steps) {
43
+ return steps.filter((step) => UNBIND_STEP_TOOLS.has(step.tool));
44
+ }
45
+ /**
46
+ * The "same command with the new flag" the blocked/partial receipt points at.
47
+ * One purge command does instances → unbind → model cascade.
48
+ */
49
+ export function unbindPurgeCommand(schemaCode, options = {}) {
50
+ return `omc model-purge --code ${schemaCode} --unbind-references${options.purgeInstances === true ? " --purge-instances" : ""} --apply`;
51
+ }
35
52
  async function sessionFor(environment) {
36
53
  const store = new ConfigStore(defaultPaths());
37
54
  const sessions = new SessionManager(store);
@@ -181,15 +198,26 @@ export async function planPurge(options, injected) {
181
198
  const references = resolved.treeRows.length > 0 ? await inboundModelReferences(session, [options.schemaCode], resolved.treeRows) : [];
182
199
  if (references.length > 0) {
183
200
  const refusal = inboundReferenceRefusal(options.schemaCode, references);
201
+ const unbindEnabled = options.unbindReferences === true;
202
+ const unbindSteps = unbindDeletionSteps(refusal.deletionSteps);
203
+ const nextCommand = unbindPurgeCommand(options.schemaCode, { purgeInstances: instanceCount > 0 && !options.purgeInstances });
184
204
  referencePreview = {
185
205
  inboundReferences: references,
186
206
  deletionSteps: refusal.deletionSteps,
187
207
  deletionOrder: purgeDeletionOrder(refusal.deletionSteps),
188
- nextCommand: refusal.nextCommand,
208
+ nextCommand,
209
+ ...(unbindEnabled ? { unbindReferences: true, unbindSteps: purgeDeletionOrder(unbindSteps) } : {}),
189
210
  referenceNotice: `${options.schemaCode} 有入站引用(${refusal.referencingModels.map((model) => model.schemaCode).join("、")};` +
190
- `子表列经 parentCode 解析回本模型时属于自引用)。--apply 的 model.delete 会零写入拒绝;先按 deletionSteps 逐条拆引用(nextCommand 是第一条),再重跑本命令。`,
211
+ `子表列经 parentCode 解析回本模型时属于自引用)。` +
212
+ (unbindEnabled
213
+ ? `已开启 --unbind-references:本命令会先按 deletionSteps 执行拆引用(${unbindSteps.map((step) => step.tool).join(" → ")};` +
214
+ `**破坏性:会删除引用列/子表关联列,列数据不可恢复**),全部成功后再让 model.delete 级联;任一步失败即停,不会删模型。`
215
+ : `--apply 的 model.delete 会零写入拒绝;nextCommand 是加上 --unbind-references 的同一条命令(本命令会自动拆引用;` +
216
+ `**破坏性:会删除引用列/子表关联列,列数据不可恢复**),也可以自己按 deletionSteps 逐条执行。`),
191
217
  };
192
- steps.push(`⛔ 入站引用:先执行 deletionSteps(${refusal.deletionSteps[0]?.command ?? ""}),再删模型`);
218
+ steps.push(unbindEnabled
219
+ ? `🔧 拆引用(--unbind-references):${unbindSteps.map((step) => step.command).join(" → ")} → 再删模型`
220
+ : `⛔ 入站引用:先执行 deletionSteps(${refusal.deletionSteps[0]?.command ?? ""}),再删模型`);
193
221
  }
194
222
  }
195
223
  catch {
@@ -293,10 +321,12 @@ export async function cmdModelPurge(args) {
293
321
  const environment = flag("--env") ?? flag("--environment");
294
322
  const apply = args.includes("--apply");
295
323
  const purgeInstances = args.includes("--purge-instances");
324
+ const unbindReferences = args.includes("--unbind-references");
296
325
  const usage = [
297
- "用法:omc model-purge --code <模型code> [--purge-instances] [--env <环境>] [--apply]",
326
+ "用法:omc model-purge --code <模型code> [--purge-instances] [--unbind-references] [--env <环境>] [--apply]",
298
327
  " 一条命令按依赖倒序清掉:列表视图 → 自建业务规则 → 流程实例 → 流程 → 模型(字段/表单/计算规则/预置规则随模型级联)。",
299
328
  " 默认 dry-run(只列计划,不写)。--purge-instances 才删流程实例(workflow.delete 遇到实例会 402508)。",
329
+ " --unbind-references 才会先按 deletionSteps 拆入站引用(field.delete 引用列 + field.publish 所属模型,**破坏性:列数据不可恢复**),再删模型。",
300
330
  " 每步回读确认;某步失败即停并说明已完成到哪一步(幂等,可修好后重跑)。",
301
331
  ].join("\n");
302
332
  const invalid = (message) => {
@@ -305,7 +335,7 @@ export async function cmdModelPurge(args) {
305
335
  };
306
336
  if (!schemaCode)
307
337
  return invalid("--code 必填");
308
- const options = { schemaCode, apply, purgeInstances, ...(environment !== undefined ? { environment } : {}) };
338
+ const options = { schemaCode, apply, purgeInstances, unbindReferences, ...(environment !== undefined ? { environment } : {}) };
309
339
  let plan;
310
340
  try {
311
341
  plan = await planPurge(options);
@@ -317,12 +347,20 @@ export async function cmdModelPurge(args) {
317
347
  }
318
348
  if (!apply) {
319
349
  const referenced = plan.inboundReferences !== undefined && plan.inboundReferences.length > 0;
350
+ const unbindEnabled = plan.unbindReferences === true;
320
351
  writeEnvelope(envelope("ok", {
321
- status: plan.blockers.length > 0 || referenced ? "blocked" : "dry-run",
352
+ status: plan.blockers.length > 0 || (referenced && !unbindEnabled) ? "blocked" : "dry-run",
322
353
  ...plan,
323
354
  ...(plan.blockers.length > 0
324
355
  ? {}
325
- : { note: `dry-run 只列计划、不写。--apply 按上面的顺序执行;每步回读确认。${referenced ? "入站引用已预扫(与 model.delete 同一份 gate):model.delete 会零写入拒绝,先按 deletionSteps 拆引用。" : ""}` }),
356
+ : {
357
+ note: `dry-run 只列计划、不写。--apply 按上面的顺序执行;每步回读确认。` +
358
+ (referenced
359
+ ? unbindEnabled
360
+ ? `已开启 --unbind-references:--apply 会先执行 unbindSteps(${(plan.unbindSteps ?? []).join(" → ")};**破坏性:会删除引用列/子表关联列,列数据不可恢复**),再把 model.delete 交给主流程级联。`
361
+ : `入站引用已预扫(与 model.delete 同一份 gate):model.delete 会零写入拒绝;nextCommand 是加上 --unbind-references 的同一条命令(**破坏性:会删除引用列/子表关联列,列数据不可恢复**),也可以自己按 deletionSteps 逐条拆。`
362
+ : ""),
363
+ }),
326
364
  }, request));
327
365
  return CLI_EXIT_CODES.ok;
328
366
  }
@@ -348,6 +386,60 @@ export async function cmdModelPurge(args) {
348
386
  writeEnvelope(envelope(classified.status, result, request, classified.error));
349
387
  return execution.failed ? 1 : 0;
350
388
  }
389
+ const invalidStepMessage = "步骤参数不完整,拒绝执行(只按 deletionSteps 逐字执行 field.delete/field.publish,不执行任意命令)";
390
+ /**
391
+ * Execute the unlink half of `deletionSteps` in order. Stops at the first
392
+ * failure; the caller must then skip `model.delete` (a half-unlinked model must
393
+ * not disappear). Never runs anything outside `field.delete`/`field.publish`.
394
+ */
395
+ export async function executeUnbindSteps(call, steps) {
396
+ const candidates = unbindDeletionSteps(steps);
397
+ const produced = [];
398
+ const executed = [];
399
+ for (let index = 0; index < candidates.length; index += 1) {
400
+ const step = candidates[index];
401
+ const label = step.tool === "field.delete"
402
+ ? `field.delete:${String(step.args.schemaCode ?? "")}.${String(step.args.code ?? "")}`
403
+ : `field.publish:${String(step.args.schemaCode ?? "")}`;
404
+ const schemaCode = step.args.schemaCode;
405
+ const code = step.args.code;
406
+ const shapeValid = typeof schemaCode === "string" &&
407
+ schemaCode.length > 0 &&
408
+ (step.tool !== "field.delete" || (typeof code === "string" && code.length > 0));
409
+ if (!shapeValid) {
410
+ produced.push({ step: label, status: "failed", detail: { code: "unbind-step-malformed", message: invalidStepMessage } });
411
+ return { failed: true, steps: produced, executed, remaining: candidates.slice(index), failedStep: label, failureMessage: invalidStepMessage };
412
+ }
413
+ let ok = false;
414
+ let failureMessage;
415
+ try {
416
+ const outcome = await call(step.tool, step.args);
417
+ ok = outcome.ok;
418
+ if (!ok)
419
+ failureMessage = typeof outcome.result.message === "string" && outcome.result.message.length > 0 ? outcome.result.message : refusalText(outcome.result);
420
+ }
421
+ catch (error) {
422
+ failureMessage = error instanceof Error ? error.message : String(error);
423
+ }
424
+ produced.push({
425
+ step: label,
426
+ status: ok ? "ok" : "failed",
427
+ ...(ok ? {} : { detail: { message: failureMessage ?? "平台拒绝" } }),
428
+ });
429
+ if (!ok) {
430
+ return {
431
+ failed: true,
432
+ steps: produced,
433
+ executed,
434
+ remaining: candidates.slice(index),
435
+ failedStep: label,
436
+ failureMessage: failureMessage ?? "平台拒绝",
437
+ };
438
+ }
439
+ executed.push(label);
440
+ }
441
+ return { failed: false, steps: produced, executed, remaining: [] };
442
+ }
351
443
  /**
352
444
  * Write phase: instances → `model.delete`, then build the receipt. Split from
353
445
  * `cmdModelPurge` so the failure pass-through can be exercised without a live
@@ -382,6 +474,17 @@ export async function executePurge(plan, session, call) {
382
474
  steps.push(...instanceOutcome.steps);
383
475
  let failed = instanceOutcome.failed;
384
476
  const unremovableInstances = instanceOutcome.unremovableInstances;
477
+ // F7(0.8.9,探针 D):`--unbind-references` 才执行拆引用。只跑
478
+ // deletionSteps 里的 field.delete/field.publish(model.delete 仍由本命令的
479
+ // 主流程负责,绝不重复)。任一步失败即停,模型不删。
480
+ let unbindOutcome;
481
+ if (!failed && plan.unbindReferences === true && (plan.deletionSteps?.length ?? 0) > 0) {
482
+ const candidates = plan.deletionSteps ?? [];
483
+ unbindOutcome = await executeUnbindSteps(call, candidates);
484
+ steps.push(...unbindOutcome.steps);
485
+ if (unbindOutcome.failed)
486
+ failed = true;
487
+ }
385
488
  // 2) the model — everything else cascades with it.
386
489
  let referrers = [];
387
490
  // F9(0.8.8,探针 C):内层 model.delete 的零写入拒绝已带 inboundReferences /
@@ -409,31 +512,48 @@ export async function executePurge(plan, session, call) {
409
512
  }
410
513
  }
411
514
  const status = failed ? "partial" : "ok";
515
+ const rerunCommand = unbindPurgeCommand(schemaCode);
412
516
  // Pass the inner refusal through verbatim; the purge-level receipt must not
413
517
  // promise keys it dropped (F9: message named deletionSteps that were absent).
414
- const failureFields = deleteRefusal !== undefined
518
+ const failureFields = unbindOutcome?.failed === true
415
519
  ? {
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
520
  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
- };
521
+ unbindReferences: true,
522
+ failedStep: unbindOutcome.failedStep,
523
+ remainingSteps: unbindOutcome.remaining,
524
+ modelDeletePending: true,
525
+ nextCommand: rerunCommand,
526
+ message: `${schemaCode} 未删除:拆引用在 ${unbindOutcome.failedStep ?? "某一步"} 失败,已停在该步;` +
527
+ `**未调用 model.delete,模型仍存在**。原因:${unbindOutcome.failureMessage ?? "平台拒绝"}。` +
528
+ `已成功的拆引用步骤不回滚(幂等,重跑不会重复破坏);修复后重跑本命令(nextCommand)继续。`,
529
+ }
530
+ : deleteRefusal !== undefined
531
+ ? {
532
+ nextAction: "execute-deletion-steps",
533
+ inboundReferences: deleteRefusal.inboundReferences,
534
+ deletionSteps: deleteRefusal.deletionSteps,
535
+ deletionOrder: purgeDeletionOrder(deleteRefusal.deletionSteps),
536
+ nextCommand: rerunCommand,
537
+ ...(referrers.length > 0 ? { blockedBy: referrers } : {}),
538
+ message: `${schemaCode} 未删除(零写入拒绝,未启动平台删除任务)。${deleteRefusal.message} ` +
539
+ `两条路:① 一条命令自动拆引用:nextCommand(--unbind-references;**破坏性:会删除指向本模型的引用列/子表关联列,列数据不可恢复**),` +
540
+ `拆完引用后由 model.delete 级联;② 自己按 deletionSteps 逐条执行。不要在未拆引用时重试 --apply(不带 --unbind-references 仍会零写入拒绝)。`,
541
+ }
542
+ : {
543
+ nextAction: "fix-and-rerun",
544
+ ...(referrers.length > 0 ? { blockedBy: referrers } : {}),
545
+ message: referrers.length > 0
546
+ ? `${schemaCode} 仍被 ${referrers.join("、")} 的关联字段引用,模型不能删。先跑 omc model-purge --code ${schemaCode}(dry-run)拿 inboundReferences / deletionSteps;` +
547
+ `再加 --unbind-references --apply 让一条命令自动拆引用(破坏性:会删除引用列),或逐条拆后再 --apply。`
548
+ : "在失败的这一步停下(幂等,可修好后重跑同一条命令)。已成功的步骤不会重复破坏。",
549
+ };
432
550
  const result = {
433
551
  status,
434
552
  schemaCode,
435
553
  verdict: plan.modelExists && !failed ? "cascading" : "clean",
436
554
  ...(plan.workflowCode !== undefined ? { workflowCode: plan.workflowCode } : {}),
555
+ ...(plan.unbindReferences === true ? { unbindReferences: true } : {}),
556
+ ...(unbindOutcome !== undefined ? { unboundSteps: unbindOutcome.executed, unbindFailed: unbindOutcome.failed } : {}),
437
557
  deletedInstances: steps.filter((step) => step.step.startsWith("workflow.delete_instance:") && step.status === "ok").length,
438
558
  ...(unremovableInstances.length > 0 ? { unremovableInstances } : {}),
439
559
  steps,
@@ -447,7 +567,9 @@ export async function executePurge(plan, session, call) {
447
567
  maintainerAction: `DELETE FROM biz_workflow_instance WHERE id IN (${unremovableInstances.map((item) => `'${item.id}'`).join(", ")});`,
448
568
  }
449
569
  : {
450
- note: "已清理:流程实例逐个删除 → model.delete 级联带走流程模板/列表视图/字段/表单/业务规则。" +
570
+ note: "已清理:流程实例逐个删除 → " +
571
+ (unbindOutcome !== undefined ? "拆入站引用(field.delete 引用列 → field.publish 所属模型)→ " : "") +
572
+ "model.delete 级联带走流程模板/列表视图/字段/表单/业务规则。" +
451
573
  "model.delete 是平台异步任务(建删除历史后立即返回,级联时长不定),稍后仍能读到模型记录属正常残留,重跑本命令即可(幂等)。" +
452
574
  "**这就是 r12–r14 三次脏沙盒的根治**:实例先走,就不会留下指向空模板的待办。",
453
575
  }),