@stalfh233/omc-cli 0.6.91 → 0.6.93

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.
@@ -426,7 +426,7 @@ export const bizserviceCapability = {
426
426
  // BusinessRuleFacadeImpl.java:370-381) and leaves stale mapping rows.
427
427
  const referenceCount = live.referenceCount ?? 0;
428
428
  if (referenceCount > 0)
429
- refuse("intent-service-referenced", `业务服务 ${service.code} 仍被 ${referenceCount} 条规则映射引用(平台删服务不做任何引用校验,但删完后引用它的规则会存不回去)。两条路:①推荐——先把引用规则里的服务节点解绑并 apply(rule.save),再单独 apply 本删除;②确知要绕过声明式门:omc call service.delete --args '{"serviceCode":"${service.code}"}'(平台会级联删方法且留下 h_biz_method_mapping 残留,同码重建后方法仍可能 500108)。注意一次 apply 不能既解绑又删服务:bizservice 能力早于 businessrule 执行`, { resource, serviceCode: service.code, referenceCount });
429
+ refuse("intent-service-referenced", `业务服务 ${service.code} 仍被 ${referenceCount} 条规则映射引用(平台删服务不做任何引用校验,但删完后引用它的规则会存不回去)。两条路:①推荐——先把引用规则里的服务节点解绑并 apply(rule.save),再单独 apply 本删除;②确知要绕过声明式门:omc call service.delete --args '{"serviceCode":"${service.code}","confirmCascade":true}'(平台会级联删方法且留下 h_biz_method_mapping 残留,同码重建后方法仍可能 500108)。注意一次 apply 不能既解绑又删服务:bizservice 能力早于 businessrule 执行`, { resource, serviceCode: service.code, referenceCount });
430
430
  emit.change("service.delete", { serviceCode: service.code }, resource, "service-declared-absent");
431
431
  continue;
432
432
  }
@@ -17,6 +17,12 @@ import { BIZSERVICE_WRITE_ADAPTERS, assertBizServiceAdapterWhitelisted, assertSt
17
17
  import { omcCore } from "../omc-core-lazy.js";
18
18
  const B2_LANE = B2_LANE_CONTRACT.lane;
19
19
  const B2_TOOLS = B2_LANE_CONTRACT.tools;
20
+ /**
21
+ * P1(2026-11-22):确认级联删服务后的残留说明。平台对 service/delete 不做
22
+ * 引用校验,级联删方法时也不会清掉规则侧的 h_biz_method_mapping 行——同码重建
23
+ * 服务/方法后,残留行仍可能让方法删除回 500108,且不会自愈。
24
+ */
25
+ const serviceCascadeResidueNote = "h_biz_method_mapping 残留不会自愈;同码重建后若方法仍 500108,需平台侧清理";
20
26
  /** Decode a JSON-string column (configJson/inputParametersJson/…); policy: non-strings null-coalesce, unparseable passes through. */
21
27
  function decodeJsonColumn(value) {
22
28
  return decodeSharedJsonColumn(value, JSON_COLUMN_NULL_COALESCE);
@@ -1559,12 +1565,105 @@ export function registerB2Lane(tools) {
1559
1565
  lane: B2_LANE,
1560
1566
  scope: B2_TOOLS["service.delete"].scope,
1561
1567
  description: B2_TOOLS["service.delete"].description,
1562
- inputSchema: { serviceCode: z.string().min(1) },
1568
+ inputSchema: {
1569
+ serviceCode: z.string().min(1),
1570
+ confirmCascade: z.boolean().optional().describe("确认级联删除:删服务会由平台级联删掉其下全部方法(BizServiceServiceImpl.java:259-273),并留下 h_biz_method_mapping 残留(同码重建后方法仍可能 500108)。被引用时默认拒绝;确要级联就带它重发"),
1571
+ },
1572
+ // P1(2026-11-22,F6 收口):删服务是 method.delete 的「裸逃生口」——平台
1573
+ // 对 service/delete 零引用校验(BizServiceController.java:139-160),级联删掉
1574
+ // 其下全部方法(BizServiceServiceImpl.java:259-273),并留下 h_biz_method_mapping
1575
+ // 残留。于是「方法被绑定 → 删服务」绕过了 method.delete 的 500108 与共用扫描。
1576
+ // 本 lint 用平台自己的 count_mapping(服务级聚合)在**任何写 wire 之前**拦下,
1577
+ // 与 method.delete 同一套共享扫描/回执形状;dry-run 与真写共用本函数(write.ts)。
1578
+ writeLint: async (session, args) => {
1579
+ const found = await wireCall(session, { path: ENDPOINTS.bizServiceGetByCode, query: { serviceCode: args.serviceCode } });
1580
+ // A missing service stays idempotent-ok (execute's absent branch).
1581
+ if (found.data == null)
1582
+ return { wouldChange: false, servicePresent: false, summary: `业务服务不存在:${args.serviceCode}——真写会回 absent(零写入)` };
1583
+ let count;
1584
+ try {
1585
+ // Service-level count: NO serviceMethodCode (the platform aggregates the
1586
+ // mapping rows under the service).
1587
+ count = await countMethodMapping(session, args.serviceCode);
1588
+ }
1589
+ catch {
1590
+ // A failed count is not evidence of "no references"; the platform has no
1591
+ // gate here, but a read-face fault must not be treated as guilt (same
1592
+ // stance as ticket 04's rule.save gate).
1593
+ return { wouldChange: true, serviceCode: args.serviceCode, referenceCountUnknown: true, summary: `count_mapping 读取失败:${args.serviceCode} 的引用计数未知(不阻塞;平台删服务本身无引用校验)` };
1594
+ }
1595
+ let methods = [];
1596
+ try {
1597
+ methods = wireRows((await wireCall(session, { path: ENDPOINTS.bizServiceMethodList, query: { serviceCode: args.serviceCode, filterFlag: "false" } })).data)
1598
+ .map((row) => ({ code: String(row.code ?? ""), referenced: row.referenced === true }))
1599
+ .filter((method) => method.code !== "");
1600
+ }
1601
+ catch {
1602
+ methods = [];
1603
+ }
1604
+ if (count <= 0)
1605
+ return { wouldChange: true, serviceCode: args.serviceCode, referenceCount: count, methods };
1606
+ if (args.confirmCascade === true)
1607
+ return {
1608
+ wouldChange: true,
1609
+ serviceCode: args.serviceCode,
1610
+ referenceCount: count,
1611
+ methods,
1612
+ cascadeConfirmed: true,
1613
+ residueNote: serviceCascadeResidueNote,
1614
+ };
1615
+ const { sites, coverage } = await scanMethodReferenceSites(session, args.serviceCode);
1616
+ const shown = sites.slice(0, 3).map((site) => `${site.schemaCode}/${site.ruleCode}#${site.nodeCode}${site.serviceMethodCode !== undefined ? `(${site.serviceMethodCode})` : ""}`).join("、");
1617
+ throw new ToolRefusalError({
1618
+ status: "refused",
1619
+ blocker: "service-referenced",
1620
+ serviceCode: args.serviceCode,
1621
+ referenceCount: count,
1622
+ methods,
1623
+ references: sites,
1624
+ coverage,
1625
+ ...(sites.length === 0
1626
+ ? { scanNote: `本次扫描未命中引用点(count_mapping 计数 ${count} > 0)——零命中不代表无引用;可能来自未扫到的应用或非规则引用` }
1627
+ : {}),
1628
+ message: `业务服务 ${args.serviceCode} 仍被 ${count} 条规则映射引用——删服务会由平台级联删掉其下全部方法(BizServiceServiceImpl.java:259-273),并留下 h_biz_method_mapping 残留(同码重建后方法仍可能 500108)。本次零写入;确要级联就带 confirmCascade:true 重发(高危,必须用户决策)。${sites.length > 0 ? `引用点:${shown}${sites.length > 3 ? ` 等 ${sites.length} 处` : ""}` : "本次扫描零命中,不等于无引用。"}`,
1629
+ doNot: "不要为了删服务而先解绑规则;解绑是独立高危写入(rule.save 需 confirmUnlink:true),必须用户决策",
1630
+ options: [
1631
+ {
1632
+ id: "read-only",
1633
+ destructive: false,
1634
+ summary: "保留服务与其下方法,先不动规则;本次未删除、未改任何配置",
1635
+ },
1636
+ {
1637
+ id: "cascade",
1638
+ destructive: true,
1639
+ requiresConfirmation: true,
1640
+ summary: "确要级联删服务就带 confirmCascade:true 重发(平台会级联删其下全部方法,并留下 h_biz_method_mapping 残留)",
1641
+ note: "本工具不会自动解绑,也不提供解绑步骤;解绑是独立的高危写入(rule.save 需 confirmUnlink:true),必须由用户决策后另行执行",
1642
+ },
1643
+ ],
1644
+ nextCommand: `omc call rule.references --args '{"kind":"service","code":"${args.serviceCode}"}'`,
1645
+ });
1646
+ },
1563
1647
  execute: async (session, args) => {
1564
1648
  const found = await wireCall(session, { path: ENDPOINTS.bizServiceGetByCode, query: { serviceCode: args.serviceCode } });
1565
1649
  const id = found.data?.id;
1566
1650
  if (typeof id !== "string" || !id)
1567
1651
  return { performed: { errcode: 0 }, readback: { absent: true, note: "service already absent" } };
1652
+ // Only the explicit cascade path may report a cascade: re-read the
1653
+ // platform count right before the delete (the gate already refused the
1654
+ // unconfirmed case) so a confirmed delete on a genuinely unreferenced
1655
+ // service does not claim a residue it never created.
1656
+ let cascadeReadback = {};
1657
+ if (args.confirmCascade === true) {
1658
+ try {
1659
+ const count = await countMethodMapping(session, args.serviceCode);
1660
+ if (count > 0)
1661
+ cascadeReadback = { cascadeConfirmed: true, cascadeReferenceCount: count, residueNote: serviceCascadeResidueNote };
1662
+ }
1663
+ catch {
1664
+ // Unknown ≠ zero: stay silent rather than claim a residue.
1665
+ }
1666
+ }
1568
1667
  const performed = await wireCall(session, { path: ENDPOINTS.bizServiceDelete, method: "POST", query: { id } });
1569
1668
  let absent = false;
1570
1669
  try {
@@ -1588,7 +1687,7 @@ export function registerB2Lane(tools) {
1588
1687
  // methods are unreachable, which is the observable absence.
1589
1688
  methodsAbsent = true;
1590
1689
  }
1591
- return { performed: { errcode: performed.errcode }, readback: { absent: absent && methodsAbsent, serviceRowAbsent: absent, methodsAbsent } };
1690
+ return { performed: { errcode: performed.errcode }, readback: { absent: absent && methodsAbsent, serviceRowAbsent: absent, methodsAbsent, ...cascadeReadback } };
1592
1691
  },
1593
1692
  });
1594
1693
  // -------------------------------------------------------------------------
@@ -5,7 +5,7 @@ import { governedRead } from "../read.js";
5
5
  import { writeTool } from "../write.js";
6
6
  import { decodeJsonColumn, JSON_COLUMN_NULL_COALESCE } from "../json-column.js";
7
7
  import { applicationResolutionOf, applicationScopeHint, flattenTreeRows, resolveApplicationScope, suggestModelNames } from "../support.js";
8
- import { assertRuleNamePlatformAcceptable, executeRuleSaveWrite, lintRuleGraphForWrite, lintRuleSaveWrite, ruleNodeGraphArg } from "../rule-support.js";
8
+ import { assertMethodRefsNotUnbound, assertRuleNamePlatformAcceptable, executeRuleSaveWrite, lintRuleGraphForWrite, lintRuleSaveWrite, ruleNodeGraphArg } from "../rule-support.js";
9
9
  import { defineTool, isRequiredAlternativePlaceholder, ToolInputError, ToolRefusalError } from "../tool-types.js";
10
10
  import { resolveRuleRowId } from "../identity.js";
11
11
  import { extractDataRuleEdges, extractReferenceEdges } from "../graph.js";
@@ -992,6 +992,11 @@ async function scanSchemaTriggers(session, args) {
992
992
  const onlineRows = hits.length === 0
993
993
  ? []
994
994
  : [{ via: "onlinejs", sheetCode, scanMode: "text", hitCount: hits.length, ...(mode === "sites" ? { hits } : {}) }];
995
+ // P4(2026-11-22,F6b):**覆盖面自述**。F6b 转录:任务说「别漏」时,agent 拿到
996
+ // 触发视图后仍逐面交叉核对 datarule/programming/视图——因为回执只说了"扫了什么",
997
+ // 没说"哪些面本来就不在这里"。把未覆盖面按入口点名列出来,省掉这轮盲目核对;
998
+ // 视图/权限不是动作触发点,单独说明"不适用",避免继续查。
999
+ notScanned.push(`数据规则(datarule)不在本视图:按字段/记录条件触发的数据规则走 omc call datarule.list --args '{"schemaCode":"${schemaCode}"}'`, `后端在线开发(programming)不在本视图:程序源码走 omc call programming.sources --args '{"schemaCode":"${schemaCode}"}'`, "视图(listview)/字段权限/流程权限不是动作触发点(只影响显示与可达性),无需扫描", "只扫当前应用;跨应用流程与规则需显式换应用(workflow.list --applicationCode)");
995
1000
  // 6. 并集 + action/activityCode 过滤(分组顺序:workflow → button → rule → preset → onlinejs)。
996
1001
  let triggers;
997
1002
  if (activityCodeFilter !== undefined) {
@@ -2003,12 +2008,16 @@ export function registerBusinessRuleLane(tools) {
2003
2008
  .describe("单条映射局部 patch:只改 select 命中的那一条映射(与 patch 可并用,但不得与 patch 同时写同一数组)"),
2004
2009
  publish: z.boolean().optional().describe("改完同样顺带 publish(默认 false,仅存草稿;生效仍需 rule.enable)"),
2005
2010
  customTrigger: z.boolean().optional(),
2011
+ confirmUnlink: z.boolean().optional().describe("确认解绑:本次 patch 会让方法映射引用消失(改指向/移除 methodMapping)时默认拒绝;确要解绑就带它重发(高危,必须用户决策)"),
2006
2012
  },
2007
2013
  execute: async (session, args) => {
2008
2014
  const base = await loadRuleNodePatchGraph(session, args);
2009
- // A4:patch 入口的统一状态段——operation:"patch" + target.nodeCode(图仍是
2010
- // 整图重存,graph.saved:true 报的是全图,与 rule.save 同构)。
2011
- const result = await executeRuleSaveWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, name: base.ruleName, nodeGraph: base.mergedGraph, ...(args.publish === true ? { publish: true } : {}), ...(args.customTrigger === true ? { customTrigger: true } : {}) }, { operation: "patch", nodeCode: args.nodeCode });
2015
+ // P2(2026-11-22,F6 收口):patch 与 rule.save 共用同一道解绑硬门——
2016
+ // 把 methodMapping 改指向另一个已存在的方法/服务就能让本方法的引用消失
2017
+ // 并打开它的删除门,所以 unlink 门对 origin.operation:"patch" 不再跳过。
2018
+ // executeRuleSaveWrite 内部走 lintRuleSaveWrite(含 assertMethodRefsNotUnbound),
2019
+ // confirmUnlink 必须原样透传,否则 gate 的 ToolRefusalError 之外的路径会缺 flag。
2020
+ const result = await executeRuleSaveWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, name: base.ruleName, nodeGraph: base.mergedGraph, ...(args.publish === true ? { publish: true } : {}), ...(args.customTrigger === true ? { customTrigger: true } : {}), ...(args.confirmUnlink === true ? { confirmUnlink: true } : {}) }, { operation: "patch", nodeCode: args.nodeCode });
2012
2021
  // F3:mapping 面的回执增量(选中数组/下标/标识/改了哪些键)——readback 顶层
2013
2022
  // additive 键;ruleStatus 共享形状不动,未选中的部分不变由整图合并语义保证。
2014
2023
  return base.mappingReceipt === undefined ? result : { ...result, readback: { ...result.readback, mappingPatch: { nodeCode: args.nodeCode, ...base.mappingReceipt } } };
@@ -2022,6 +2031,16 @@ export function registerBusinessRuleLane(tools) {
2022
2031
  // name 校验与真写同源(真写在 executeRuleSaveWrite 里再跑一次同一函数;
2023
2032
  // name 取存量行,预置触发行在函数内部跳过)。
2024
2033
  assertRuleNamePlatformAcceptable(args.ruleCode, base.ruleName);
2034
+ // P2(2026-11-22):dry-run 与真写同门——解绑硬门用本次已读到的活行图
2035
+ // (base.record.node)与 patch 合并后的图比较,零额外 wire、同一答案。
2036
+ assertMethodRefsNotUnbound({
2037
+ schemaCode: args.schemaCode,
2038
+ ruleCode: args.ruleCode,
2039
+ name: base.ruleName,
2040
+ liveNodes: base.record.node,
2041
+ nextNodes: base.mergedGraph.nodes,
2042
+ confirmUnlink: args.confirmUnlink,
2043
+ });
2025
2044
  const linted = await lintRuleGraphForWrite(session, { schemaCode: args.schemaCode, ruleCode: args.ruleCode, nodeGraph: base.mergedGraph, ...(args.customTrigger === true ? { customTrigger: true } : {}) }, { validationRefusalMessage: "nodeGraph 未过出门前校验(dry lint,与真写同门);按 validation 逐项修正" });
2026
2045
  return {
2027
2046
  nodeCode: args.nodeCode,
@@ -1,7 +1,7 @@
1
1
  import { ENDPOINTS } from "./endpoints.js";
2
2
  import { decodeJsonColumn, JSON_COLUMN_NULL_COALESCE } from "./json-column.js";
3
3
  import { wireCall, wireRows } from "./wire.js";
4
- export const METHOD_REFERENCE_LIMITS = { models: 25, rules: 50, sites: 8 };
4
+ export const METHOD_REFERENCE_LIMITS = { models: 25, rules: 50, sites: 8, methods: 25 };
5
5
  /** Platform reference count: GET /app/bizmethod/count_mapping → Integer. Failures throw. */
6
6
  export async function countMethodMapping(session, serviceCode, methodCode) {
7
7
  const response = await wireCall(session, {
@@ -15,15 +15,19 @@ export async function countMethodMapping(session, serviceCode, methodCode) {
15
15
  return Number.isFinite(parsed) ? parsed : 0;
16
16
  }
17
17
  /**
18
- * Node codes in one rule graph whose `methodMapping` points at exactly this
19
- * service+method. The `node` column may arrive as a JSON string or an array;
20
- * anything else (corrupt column, object, null) yields no hits.
18
+ * Node codes in one rule graph whose `methodMapping` points at this service
19
+ * (and, when `methodCode` is given, exactly this method of it). The `node`
20
+ * column may arrive as a JSON string or an array; anything else (corrupt
21
+ * column, object, null) yields no hits.
22
+ *
23
+ * A blank `serviceMethodCode` is not a reference (`methodMappingRefsOf` drops
24
+ * it too: the platform maps nothing), so the service-level form skips it.
21
25
  */
22
- function mappedMethodNodeCodes(nodeColumn, serviceCode, methodCode) {
26
+ function mappedMethodNodes(nodeColumn, serviceCode, methodCode) {
23
27
  const decoded = decodeJsonColumn(nodeColumn, JSON_COLUMN_NULL_COALESCE);
24
28
  if (!Array.isArray(decoded))
25
29
  return [];
26
- const nodeCodes = [];
30
+ const hits = [];
27
31
  for (const entry of decoded) {
28
32
  if (!entry || typeof entry !== "object" || Array.isArray(entry))
29
33
  continue;
@@ -32,13 +36,16 @@ function mappedMethodNodeCodes(nodeColumn, serviceCode, methodCode) {
32
36
  if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
33
37
  continue;
34
38
  const mapped = mapping;
35
- if (String(mapped.serviceCode ?? "") !== serviceCode || String(mapped.serviceMethodCode ?? "") !== methodCode)
39
+ if (String(mapped.serviceCode ?? "") !== serviceCode)
40
+ continue;
41
+ const mappedMethod = String(mapped.serviceMethodCode ?? "");
42
+ if (methodCode !== undefined ? mappedMethod !== methodCode : mappedMethod === "")
36
43
  continue;
37
44
  const nodeCode = String(node.nodeCode ?? "");
38
45
  if (nodeCode !== "")
39
- nodeCodes.push(nodeCode);
46
+ hits.push({ nodeCode, serviceMethodCode: mappedMethod });
40
47
  }
41
- return nodeCodes;
48
+ return hits;
42
49
  }
43
50
  /**
44
51
  * Ticket 04 (2026-11-21, F6) — every method mapping carried by one rule graph,
@@ -73,9 +80,16 @@ export function methodMappingRefsOf(nodes) {
73
80
  }
74
81
  /**
75
82
  * Best-effort reference identity: viewReference → schemaCodes (≤25) → per-model
76
- * rule list (≤50 rules) → per-rule graph read → methodMapping match
77
- * (serviceCode + serviceMethodCode). A single failed read only lands in
78
- * `coverage`; sites stop at 8 and the coverage says the scan was truncated.
83
+ * rule list (≤50 rules) → per-rule graph read → methodMapping match. A single
84
+ * failed read only lands in `coverage`; sites stop at 8 and the coverage says
85
+ * the scan was truncated.
86
+ *
87
+ * `methodCode` omitted = service-level scan (P1, `service.delete`): the
88
+ * platform count is service-wide (`count_mapping` without serviceMethodCode),
89
+ * so the sites must be too. Model discovery then unions the un-suffixed read
90
+ * (platforms that aggregate) with one `viewReference` per method in the
91
+ * service's method list (≤25; the fake and the per-method platform face only
92
+ * answer the exact method code).
79
93
  */
80
94
  export async function scanMethodReferenceSites(session, serviceCode, methodCode) {
81
95
  const sites = [];
@@ -90,22 +104,67 @@ export async function scanMethodReferenceSites(session, serviceCode, methodCode)
90
104
  sitesReturned: 0,
91
105
  };
92
106
  let schemaCodes = [];
93
- try {
94
- const rows = wireRows((await wireCall(session, {
95
- path: ENDPOINTS.bizServiceMethodViewReference,
96
- query: { serviceCode, serviceMethodCode: methodCode },
97
- })).data);
98
- const discovered = [...new Set(rows.map((row) => String(row.schemaCode ?? "")).filter((code) => code !== ""))];
99
- coverage.modelsDiscovered = discovered.length;
100
- if (discovered.length > METHOD_REFERENCE_LIMITS.models)
101
- coverage.truncated = true;
102
- schemaCodes = discovered.slice(0, METHOD_REFERENCE_LIMITS.models);
107
+ const discovered = [];
108
+ const collectModels = (rows) => {
109
+ for (const row of rows) {
110
+ const schemaCode = String(row.schemaCode ?? "");
111
+ if (schemaCode !== "" && !discovered.includes(schemaCode))
112
+ discovered.push(schemaCode);
113
+ }
114
+ };
115
+ if (methodCode !== undefined) {
116
+ try {
117
+ collectModels(wireRows((await wireCall(session, {
118
+ path: ENDPOINTS.bizServiceMethodViewReference,
119
+ query: { serviceCode, serviceMethodCode: methodCode },
120
+ })).data));
121
+ }
122
+ catch {
123
+ // No model list: zero sites is all we can say. Callers must label it as a
124
+ // zero-HIT scan (never "no references").
125
+ return { sites, coverage };
126
+ }
103
127
  }
104
- catch {
105
- // No model list: zero sites is all we can say. Callers must label it as a
106
- // zero-HIT scan (never "no references").
107
- return { sites, coverage };
128
+ else {
129
+ // Service-level: every read is best-effort (a failure here never proves
130
+ // "no references" — the platform count stays authoritative).
131
+ try {
132
+ collectModels(wireRows((await wireCall(session, {
133
+ path: ENDPOINTS.bizServiceMethodViewReference,
134
+ query: { serviceCode },
135
+ })).data));
136
+ }
137
+ catch {
138
+ // Degrade: the per-method reads below still get a chance.
139
+ }
140
+ let methodCodes = [];
141
+ try {
142
+ methodCodes = wireRows((await wireCall(session, {
143
+ path: ENDPOINTS.bizServiceMethodList,
144
+ query: { serviceCode, filterFlag: "false" },
145
+ })).data).map((row) => String(row.code ?? "")).filter((code) => code !== "");
146
+ }
147
+ catch {
148
+ methodCodes = [];
149
+ }
150
+ if (methodCodes.length > METHOD_REFERENCE_LIMITS.methods)
151
+ coverage.truncated = true;
152
+ for (const code of methodCodes.slice(0, METHOD_REFERENCE_LIMITS.methods)) {
153
+ try {
154
+ collectModels(wireRows((await wireCall(session, {
155
+ path: ENDPOINTS.bizServiceMethodViewReference,
156
+ query: { serviceCode, serviceMethodCode: code },
157
+ })).data));
158
+ }
159
+ catch {
160
+ // Same degrade: one method's reference list unread ≠ a clean bill.
161
+ }
162
+ }
108
163
  }
164
+ coverage.modelsDiscovered = discovered.length;
165
+ if (discovered.length > METHOD_REFERENCE_LIMITS.models)
166
+ coverage.truncated = true;
167
+ schemaCodes = discovered.slice(0, METHOD_REFERENCE_LIMITS.models);
109
168
  for (const schemaCode of schemaCodes) {
110
169
  coverage.modelsScanned += 1;
111
170
  let rules = [];
@@ -134,8 +193,13 @@ export async function scanMethodReferenceSites(session, serviceCode, methodCode)
134
193
  coverage.rulesScanned += 1;
135
194
  if (!record)
136
195
  continue;
137
- for (const nodeCode of mappedMethodNodeCodes(record.node, serviceCode, methodCode)) {
138
- sites.push({ schemaCode, ruleCode, nodeCode });
196
+ for (const hit of mappedMethodNodes(record.node, serviceCode, methodCode)) {
197
+ sites.push({
198
+ schemaCode,
199
+ ruleCode,
200
+ nodeCode: hit.nodeCode,
201
+ ...(methodCode === undefined ? { serviceMethodCode: hit.serviceMethodCode } : {}),
202
+ });
139
203
  if (sites.length >= METHOD_REFERENCE_LIMITS.sites) {
140
204
  coverage.truncated = true;
141
205
  coverage.sitesReturned = sites.length;
package/dist/read.js CHANGED
@@ -245,6 +245,15 @@ function compactReadback(result) {
245
245
  compact[key] = value;
246
246
  continue;
247
247
  }
248
+ // 2026-11-21(0.6.91 真机,05b childRowsHint):教学串不是数据。hint 类
249
+ // 字符串被 summarizeValue 折成 `{length,sha256,omitted}` 等于把教学本身
250
+ // 废掉——`data.load` 的内联子表 hint 209B 就这样变成了一个摘要(读起来
251
+ // 像"有 hint",实际一个字都读不到)。与上面 small-object 同一条规则:
252
+ // 折叠它是纯损失。上限 1200B 防异常长串,超过才摘要。
253
+ if (typeof value === "string" && /Hint$/.test(key) && Buffer.byteLength(value, "utf8") <= 1200) {
254
+ compact[key] = value;
255
+ continue;
256
+ }
248
257
  const summarized = summarizeValue(value);
249
258
  compact[key] = summarized !== null && typeof summarized === "object" && !Array.isArray(summarized)
250
259
  ? { ...summarized, omitted: true }
@@ -1189,7 +1189,37 @@ function collectEmptyMappings(nodes) {
1189
1189
  }
1190
1190
  return empty;
1191
1191
  }
1192
- export async function lintRuleSaveWrite(session, args, options = {}) {
1192
+ /**
1193
+ * P2(2026-11-22,F6 收口)—— 解绑硬门的唯一实现:同一门覆盖 `rule.save` 的整图
1194
+ * 保存与 `rule.node.update` 的节点/映射 patch(两者都是「整图重存」)。
1195
+ *
1196
+ * 判据只看**引用集合的消失**:活行图里有、本次图里没有的 `serviceCode/method`。
1197
+ * 改映射参数(bizCode/required/inputMappings…)、只加绑定、挪节点全部放行;
1198
+ * 清空 methodMapping 或改指向另一个已存在的方法/服务 → 拒绝。
1199
+ *
1200
+ * 活行读不到(读面故障)时由调用方跳过本函数(不做有罪推定:无法比较引用集合
1201
+ * 即放行,不新增一条「读不到就不让保存」的硬失败面)。
1202
+ */
1203
+ export function assertMethodRefsNotUnbound(input) {
1204
+ const liveRefs = methodMappingRefsOf(input.liveNodes);
1205
+ if (liveRefs.length === 0)
1206
+ return;
1207
+ const nextRefs = new Set(methodMappingRefsOf(input.nextNodes));
1208
+ const disappearingRefs = liveRefs.filter((ref) => !nextRefs.has(ref));
1209
+ if (disappearingRefs.length === 0 || input.confirmUnlink === true)
1210
+ return;
1211
+ throw new ToolRefusalError({
1212
+ status: "refused",
1213
+ blocker: "rule-unbind-requires-confirmation",
1214
+ schemaCode: input.schemaCode,
1215
+ ruleCode: input.ruleCode,
1216
+ disappearingRefs,
1217
+ doNot: "不要为了删方法而解绑规则;这是影响生产行为的高危写入,必须用户决策",
1218
+ nextCommand: `omc call rule.save --args '{"schemaCode":"${input.schemaCode}","ruleCode":"${input.ruleCode}","name":"${input.name}","nodeGraph":<本次 nodeGraph 原样>,"confirmUnlink":true}'(确要解绑就带本次同参 + confirmUnlink:true 重发;rule.node.update 的 patch 面同带 confirmUnlink:true)`,
1219
+ message: `本次写入会让方法映射引用 ${disappearingRefs.join("、")} 从规则 ${input.schemaCode}.${input.ruleCode} 的图里消失(BIZ_ACTION 节点被删或 methodMapping 被移除/改指向)——保存后这些方法的 count_mapping 会下降,对应方法的删除门会因此打开。默认拒绝、零写入;确要解绑就带 confirmUnlink:true 重发(高危,必须用户决策)。`,
1220
+ });
1221
+ }
1222
+ export async function lintRuleSaveWrite(session, args) {
1193
1223
  // r85(issue 03/08):幻影 schema 门提前到一切规则面 wire 之前(原在图 lint 后,
1194
1224
  // 而 computeCarriedNodeCodes 已会 list——提前只收紧不放松;后续 routes 沿用
1195
1225
  // 读取/设计器保读都以 schema 已证存在为前提)。
@@ -1244,32 +1274,21 @@ export async function lintRuleSaveWrite(session, args, options = {}) {
1244
1274
  // 只**消失**的引用会拒绝(新增/改动映射参数/挪节点/只加绑定全部放行),除非
1245
1275
  // 调用方显式 `confirmUnlink:true`。零写入:本门在图 lint 之后、任何写 wire 之前。
1246
1276
  //
1247
- // 已知边界:`rule.node.update` 的节点级 patch(含整组替换 methodMapping)不在
1248
- // 本门覆盖范围——它是「单节点 patch」不是整图重画,mapping patch 本身不删节点;
1249
- // 其 execute 以 origin.operation:"patch" 显式跳过本门(lintRuleSaveWrite options)。
1250
- // 活行读不到(读面故障)时不做有罪推定:无法比较引用集合即放行,不新增一条
1251
- // 「读不到就不让保存」的硬失败面。
1252
- if (options.unlinkGate !== false && existing?.id) {
1277
+ // P2(2026-11-22,F6 收口):同一门覆盖 save 与 node patch(`rule.node.update`
1278
+ // 的 patch/mapping 面同样把整图重存,把 methodMapping 改指向另一个已存在的
1279
+ // 方法/服务就能让本方法的引用消失并打开它的删除门)。只消失的引用才拒,改映射
1280
+ // 参数/只加绑定照旧放行;判据与读法全在 `assertMethodRefsNotUnbound`。
1281
+ if (existing?.id) {
1253
1282
  const liveRow = await loadCurrentRow();
1254
- if (liveRow) {
1255
- const liveRefs = methodMappingRefsOf(liveRow.node);
1256
- if (liveRefs.length > 0) {
1257
- const nextRefs = new Set(methodMappingRefsOf(nodes));
1258
- const disappearingRefs = liveRefs.filter((ref) => !nextRefs.has(ref));
1259
- if (disappearingRefs.length > 0 && args.confirmUnlink !== true) {
1260
- throw new ToolRefusalError({
1261
- status: "refused",
1262
- blocker: "rule-unbind-requires-confirmation",
1263
- schemaCode: args.schemaCode,
1264
- ruleCode: args.ruleCode,
1265
- disappearingRefs,
1266
- doNot: "不要为了删方法而解绑规则;这是影响生产行为的高危写入,必须用户决策",
1267
- nextCommand: `omc call rule.save --args '{"schemaCode":"${args.schemaCode}","ruleCode":"${args.ruleCode}","name":"${args.name}","nodeGraph":<本次 nodeGraph 原样>,"confirmUnlink":true}'(确要解绑就带本次同参 + confirmUnlink:true 重发)`,
1268
- message: `本次保存会让方法映射引用 ${disappearingRefs.join("、")} 从规则 ${args.schemaCode}.${args.ruleCode} 的图里消失(BIZ_ACTION 节点被删或 methodMapping 被移除/改指向)——保存后这些方法的 count_mapping 会下降,对应方法的删除门会因此打开。默认拒绝、零写入;确要解绑就带 confirmUnlink:true 重发(高危,必须用户决策)。`,
1269
- });
1270
- }
1271
- }
1272
- }
1283
+ if (liveRow)
1284
+ assertMethodRefsNotUnbound({
1285
+ schemaCode: args.schemaCode,
1286
+ ruleCode: args.ruleCode,
1287
+ name: args.name,
1288
+ liveNodes: liveRow.node,
1289
+ nextNodes: nodes,
1290
+ confirmUnlink: args.confirmUnlink,
1291
+ });
1273
1292
  }
1274
1293
  await assertCreateSelectionCompatibility(session, args.schemaCode, Array.isArray(nodes) ? nodes : []);
1275
1294
  // r85(issue 08):codeType:1 映射字段预检(QUERY 上游模型解析 + did-you-mean
@@ -1555,7 +1574,7 @@ export function ruleStatusSegment(input) {
1555
1574
  }
1556
1575
  export async function executeRuleSaveWrite(session, args, origin = { operation: "save" }) {
1557
1576
  // 与 dry-run 同源:同一套只读门先跑,然后才写。
1558
- const { lintWarnings, lintHazards, bizMethodChecks, existing, customTriggerApplied, isPresetRule, bizRuleType, nodeJson, routeJson, schedulerField, schedulerSetting, nodes, routesSource, emptyMappings, preservedDesignerText, designerTextOverwritten, mappingFieldChecks, absentMappingFields, } = await lintRuleSaveWrite(session, args, { unlinkGate: origin.operation !== "patch" });
1577
+ const { lintWarnings, lintHazards, bizMethodChecks, existing, customTriggerApplied, isPresetRule, bizRuleType, nodeJson, routeJson, schedulerField, schedulerSetting, nodes, routesSource, emptyMappings, preservedDesignerText, designerTextOverwritten, mappingFieldChecks, absentMappingFields, } = await lintRuleSaveWrite(session, args);
1559
1578
  // r85(retro 2026-11-19):dry-run 与真写共用的回执增量(routes 沿用 / 空映射 /
1560
1579
  // 设计器文本保读 / 映射字段预检)。
1561
1580
  const r85Readback = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.91",
3
+ "version": "0.6.93",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "commander": "14.0.3",
59
- "omc-core": "0.6.91",
59
+ "omc-core": "0.6.93",
60
60
  "proper-lockfile": "4.1.2",
61
61
  "write-file-atomic": "6.0.0",
62
62
  "zod": "^3.23.8",
@@ -74,6 +74,6 @@
74
74
  "directory": "packages/omc-cli"
75
75
  },
76
76
  "optionalDependencies": {
77
- "@stalfh233/omc-fake-platform": "0.6.91"
77
+ "@stalfh233/omc-fake-platform": "0.6.93"
78
78
  }
79
79
  }