@stalfh233/omc-cli 0.6.86 → 0.6.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.js CHANGED
@@ -45,6 +45,7 @@ export async function executePackage(ctx, plan, coverage, args, execute) {
45
45
  steps: executed.steps,
46
46
  failedStep: executed.failedStep,
47
47
  stop: executed.envelope,
48
+ ...(executed.ruleStatus !== undefined ? { ruleStatus: executed.ruleStatus } : {}),
48
49
  ...(productionConfirmed ? { productionConfirmed: true } : {}),
49
50
  ...(reason !== undefined ? { reason } : {}),
50
51
  deliveryState: "STOPPED",
@@ -56,21 +57,26 @@ export async function executePackage(ctx, plan, coverage, args, execute) {
56
57
  steps: executed.steps,
57
58
  failedStep: executed.failedStep,
58
59
  ...executed.envelope,
60
+ // A4:中途失败也要状态段(configure_rule 的 enable 步失败时 save 已落图)。
61
+ ...(executed.ruleStatus !== undefined ? { ruleStatus: executed.ruleStatus } : {}),
59
62
  artifactFingerprint: artifactRef.detailSha256,
60
63
  };
61
64
  }
62
- const { steps, readback, summary } = executed;
65
+ const { steps, readback, summary, ruleStatus } = executed;
63
66
  const artifact = {
64
67
  plan: boundPlan,
65
68
  steps,
66
69
  readback,
70
+ ...(ruleStatus !== undefined ? { ruleStatus } : {}),
67
71
  ...(productionConfirmed ? { productionConfirmed: true } : {}),
68
72
  ...(reason !== undefined ? { reason } : {}),
69
73
  deliveryState: "DELIVERED",
70
74
  recordedAt: new Date().toISOString(),
71
75
  };
72
76
  writeArtifact(ctx, `package-${randomUUID().slice(0, 8)}.json`, artifact);
73
- return { status: "ok", deliveryState: "DELIVERED", steps, readback, ...(productionConfirmed ? { productionConfirmed: true } : {}), ...(reason !== undefined ? { reason } : {}), ...(summary !== undefined ? { summary } : {}), artifactFingerprint: sha256(artifact) };
77
+ // A4(r89 契约层):ruleStatus 透传(configure_rule 等套餐面)——与原子工具
78
+ // (write.ts)同一键、同一构造(rule-support.ts ruleStatusSegment)。
79
+ return { status: "ok", deliveryState: "DELIVERED", steps, readback, ...(ruleStatus !== undefined ? { ruleStatus } : {}), ...(productionConfirmed ? { productionConfirmed: true } : {}), ...(reason !== undefined ? { reason } : {}), ...(summary !== undefined ? { summary } : {}), artifactFingerprint: sha256(artifact) };
74
80
  });
75
81
  }
76
82
  //# sourceMappingURL=package.js.map
@@ -70,11 +70,14 @@ const READ_SHAPES = {
70
70
  },
71
71
  "data.load": {
72
72
  keys: ["bizObjectId", "exists", "data:{...}"],
73
+ // A1(同义事实对照):同一行业务列在两面包装不同——列表面套 fields,本面平铺。
74
+ // 平台证据:行本体是 FormDataVO.data(GET /runtime/form_data/get_by_id 平铺业务列)。
75
+ notes: ["业务列在 data.<code>(平铺,不套 fields);列表面 data.list 同一行是 items[].fields.<code>——跨面对照别拿错包装键"],
73
76
  },
74
77
  // r80:计数/分组统计的读回面。notes 只显首条——把陷阱并进第一句。
75
78
  "data.aggregate": {
76
- keys: ["schemaCode", "metric", "field?", "value?", "count", "nonNullCount?", "nullCount?", "groupBy?", "total", "buckets:array<{key,count,nonNullCount?,value?}>", "nullBucket:{count,nonNullCount?,value?}", "truncatedBuckets", "bucketsTruncatedCount", "unaccountedCount?", "coverage:{mode,rowsScanned,cap,complete,missingCount?}", "filter:{draftPolicy,hint}", "wire:{calls,plan,concurrency?}", "capNotice?", "note?", "environmentFingerprint"],
77
- notes: ["计数用 total(服务端 totalElements,精确);分组是「值域×count」——buckets[].key 是字段存储值/code,null 单列 nullBucket;分桶 count 扇出走有界并发(窗口 4,限流退化 2,见 wire.concurrency),桶按输入序重组后再排序,结果与串行逐字段一致;数值指标(metric=sum/avg/min/max+field)是本地折叠(cap 1000,null 行不进聚合、avg 分母排除 null),coverage.complete:false 时只覆盖已扫行,勿外推"],
79
+ keys: ["schemaCode", "metric", "field?", "value?", "count", "nonNullCount?", "nullCount?", "groupBy?", "total", "buckets:array<{key,count,nonNullCount?,value?}>", "nullBucket:{count,nonNullCount?,value?}", "truncatedBuckets", "bucketsTruncatedCount", "unaccountedCount?", "shapeWarnings?", "strategyFallback?", "coverage:{mode:server-total|paged-local-scan|local-scan|server-aggregate,rowsScanned,cap:number|null,complete,missingCount?}", "filter:{draftPolicy,hint}", "wire:{calls,plan,concurrency?}", "capNotice?", "note?", "environmentFingerprint"],
80
+ notes: ["计数用 total(totalElements);分组=值域×count,key 是存储值/code,null 单列 nullBucket;分桶 count 并发窗口 4,桶序稳定;数值指标(sum/avg/min/max+field)本地折叠(cap 1000,null 不进聚合、avg 分母排除 null);coverage.mode=server-total/paged-local-scan/local-scan/server-aggregate,/sum 不可用或形状不符回退本地(strategyFallback);complete:false 只覆盖已扫行,勿外推"],
78
81
  },
79
82
  "app.list": {
80
83
  keys: ["applications:array<{code,name,groupId?,modelCount}>", "applicationsCount", "omitted"],
@@ -92,11 +95,11 @@ const READ_SHAPES = {
92
95
  "model.inspect": {
93
96
  // Slim/compact face (window diet): field inventory is `fieldCodes`, not fields[].
94
97
  keys: ["schemaCode", "applicationCode", "fieldCodes", "form", "listview", "ruleCodes", "datarules", "workflow", "hint"],
95
- notes: ["slim 面键是 fieldCodes(不是 fields[].code);all:true 时 fields/artifact 行含 options"],
98
+ notes: ["slim 面字段清单=fieldCodes:array<string>(只有 code 清单);字段名/类型的行明细在 field.list.fields[].code——同一事实两面,别在 fieldCodes 里找 name;all:true 时 fields/artifact 行含 options"],
96
99
  },
97
100
  "field.list": {
98
101
  keys: ["fields:array<{code,name,type,...}>", "modelPresent?"],
99
- notes: ["模型不存在时平台可能 refused(300004);存在性判据优先 model.inspect.modelPresent / rule.list.modelPresent"],
102
+ notes: ["字段行键=fields[].code(带 name/type 明细);model.inspect 的 fieldCodes 是同一清单的纯 code 投影——跨面对照别拿错键", "模型不存在时平台可能 refused(300004);存在性判据优先 model.inspect.modelPresent / rule.list.modelPresent"],
100
103
  },
101
104
  "workitem.list": {
102
105
  // Flat rows — no fields bag. Wire id is projected as workItemId.
@@ -128,16 +131,21 @@ const READ_SHAPES = {
128
131
  notes: ["无流程的模型 workflowCode:null + exists:false(不是错误);平台无流程清单端点,本面按模型索引(流程-模型一对一惯例,workflowCode 常为 <模型code>_flow)", "ruleBindingCount = flow 级 handler + 节点级事件 + SYSTEM_ACTIVITY 顶层绑定的规则码总数(比 get_published 摘要里的同名键多算节点级)"],
129
132
  },
130
133
  "workflow.get_published": {
134
+ // A2 locator:模板摘要 activities[].code ↔ 实例/待办 activityCode(Activity.java:26-30
135
+ // 存储面原生键就是 activityCode/activityType/activityName;code/name/type 是摘要投影)。
136
+ locator: { templateActivityKey: "code", instanceKey: "activityCode", workitemKey: "activityCode" },
131
137
  keys: ["status", "workflowCode", "exists", "published", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]},systemBizActions?:{bizActionType,ruleCodes:[code]}}>,edges:array<{from,to}>,ruleBindings:array<{...}>,nodeRuleBindings?,systemRuleBindings?,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?,systemBizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
132
- notes: ["规则绑定三个面:流程级 ruleBindings、节点事件 activities[].bizActions、SYSTEM_ACTIVITY 顶层 activities[].systemBizActions(规则绑在系统活动节点本身、激活时执行)——三个面看完再下「没绑」结论;完整模板在 data(外置 detailArtifactId),要深层字段时投影写到叶子(如 --jq 'data.activities[].bizActions')——写整棵父节点会因总量超限再次被外置"],
138
+ notes: ["规则绑定三个面:流程级 ruleBindings、节点事件 activities[].bizActions、SYSTEM_ACTIVITY 顶层 activities[].systemBizActions(规则绑在系统活动节点本身、激活时执行)——三个面看完再下「没绑」结论;完整模板在 data(外置 detailArtifactId),要深层字段时投影写到叶子(如 --jq 'data.activities[].bizActions')——写整棵父节点会因总量超限再次被外置;activities[] 键=code/name/type,实例/待办面(workflow.instanceActivity、workitem.list)同一概念叫 activityCode/activityName(workitem 行没有 activityType)——跨面对照别拿错键"],
133
139
  },
134
140
  "workflow.get_draft": {
135
141
  keys: ["status", "workflowCode", "exists", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]},systemBizActions?:{bizActionType,ruleCodes:[code]}}>,edges:array<{from,to}>,ruleBindings:array<{...}>,nodeRuleBindings?,systemRuleBindings?,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?,systemBizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
136
142
  notes: ["与 workflow.get_published 同形(少了 published 键);节点绑定看 activities[].bizActions、系统活动顶层看 systemBizActions;templateType=DRAFT;深层字段投影写到叶子,完整模板在 data/detailArtifactId"],
137
143
  },
138
144
  // R88 #1:双面排查面。returnsFace 只显 notes 首条——教学并进首条。
145
+ // A8(r89 契约层):comparison 段钉死对比方向与算法(from=published, to=draft),
146
+ // 并明确 changes[] 不是发布 payload。
139
147
  "config.diff": {
140
- keys: ["domain:'workflow'|'form'", "target:{schemaCode,workflowCode?|sheetCode?}", "present?:boolean(form:表单槽位是否存在;false 的面缺语义看 verdict=absent)", "draft:{present,controlCount?(form)}", "published:{present,controlCount?(form)}", "changed:boolean|null(null=一面缺失不可比,配 verdict)", "verdict?:'draft-only'|'published-only'|'absent'|'both-empty'", "changes:array<{path,before,after}>(≤limit;before=发布面,after=草稿面)", "totalKnown", "truncated", "remaining?", "shapeWarnings?", "bindingFaces?:{ruleBindings,nodeRuleBindings,systemRuleBindings}(workflow)", "deepScan?:{changed,totalKnown,samplePaths?}(workflow)", "diffArtifactId?", "diffSha256?", "fetch?", "hint"],
148
+ keys: ["domain:'workflow'|'form'", "comparison:{from:'published',to:'draft',algorithm:'deepDiff-v1',note}(读回对比,不是写 payload)", "target:{schemaCode,workflowCode?|sheetCode?}", "present?:boolean(form:表单槽位是否存在;false 的面缺语义看 verdict=absent)", "draft:{present,controlCount?(form)}", "published:{present,controlCount?(form)}", "changed:boolean|null(null=一面缺失不可比,配 verdict)", "verdict?:'draft-only'|'published-only'|'absent'|'both-empty'", "changes:array<{path,before,after}>(≤limit;before=发布面,after=草稿面)", "totalKnown", "truncated", "remaining?", "shapeWarnings?", "bindingFaces?:{ruleBindings,nodeRuleBindings,systemRuleBindings}(workflow)", "deepScan?:{changed,totalKnown,samplePaths?}(workflow)", "diffArtifactId?", "diffSha256?", "fetch?", "hint"],
141
149
  notes: [
142
150
  "changed:null ≠ 空 diff——一面缺失时看 verdict(draft-only=草稿全未发布);workflow 路径形如 activities[+code]/edges[A->B]/nodeRuleBindings[Activity2.endActivity].ruleCodes[+X],form 路径前缀 view/attributes/html/actions(按控件 key 对齐,不文本 diff);totalKnown 是精确全量计数,全量差异与双面快照在 diffArtifactId",
143
151
  ],
@@ -157,7 +165,7 @@ const READ_SHAPES = {
157
165
  // 覆盖——探针只能读回执 coverage 才发现选错了面。对照进 notes[0]:
158
166
  // returnsFace 只显首条,默认 describe 面就要能先验选对面,不是打完才知道。
159
167
  "rule.references": {
160
- keys: ["kind", "code", "scanned:{models,rules,parseFailures?}", "matches:array<{schemaCode,ruleCode,nodeCode,nodeType,via,targetObjectCode?}>", "coverage:{scanned,notScanned,note}", "applicationResolution?", "note?(零命中)", "hint?"],
168
+ keys: ["kind", "code", "scanned:{models,rules,parseFailures?}", "matches:array<{schemaCode,ruleCode,nodeCode,nodeType,via,targetObjectCode?,serviceMethodCode?(kind=service)}>", "coverage:{scanned,notScanned,note}", "applicationResolution?", "note?(零命中)", "hint?"],
161
169
  notes: [
162
170
  "覆盖面对照:本工具=在线实时、仅 businessrule;omc graph references=离线快照、businessrule+datarule+listview 三面(毫秒级,需先 omc graph pull),且已含规则条件叶子(rule.condition 边;本在线面不含,条件引用走 graph);字段消歧 graph 面支持 schema.field 写法",
163
171
  "matches:[] 只代表已扫面零命中(coverage.notScanned 是权威,勿当可安全删除);字段 code 跨模型不唯一,建议配 schemaCodes 限范围",
@@ -183,9 +191,12 @@ const READ_SHAPES = {
183
191
  ],
184
192
  },
185
193
  "form.get": {
194
+ // A2 locator:控件清单键 ↔ config.diff 的逐控件差异路径(BizFormModel.java:26-32
195
+ // 六列分面存储,diff 按控件 key 对齐,前缀 view/attributes/html/actions)。
196
+ locator: { controlCodes: "publishedControlCodes|draftControlCodes", diffPath: "changes[].path" },
186
197
  keys: ["present", "published", "publishedControlCodes", "draftControlCodes", "formButtonCodes?", "formButtons?", "customButtonJson?(full)", "customButtonJsonShapeWarning?"],
187
198
  notes: [
188
- "控件清单键是 publishedControlCodes/draftControlCodes,不是 controls",
199
+ "控件清单键是 publishedControlCodes/draftControlCodes,不是 controls;两面差异的逐控件路径在 config.diff changes[].path(前缀 view/attributes/html/actions,按控件 key 对齐)",
189
200
  "表单按钮读 formButtonCodes/formButtons;full:true 另带 customButtonJson 数组原样(库里是字符串脏形时给 customButtonJsonShapeWarning——线上 #38 前端按钮不渲染,重写 buttons 自愈)",
190
201
  ],
191
202
  },
@@ -229,8 +240,8 @@ const READ_SHAPES = {
229
240
  },
230
241
  // r79-w2b(issue 06):方法清单面——一次 list 拿全部 url(不再 N 次 method.get)。
231
242
  "method.list": {
232
- keys: ["status", "serviceCode", "adapterCode", "present", "methodsCount", "columnNote", "referencedNote", "methods:array<{code,name,url,httpType,requestBodyType,inParams,outParams,configKeys}>", "keyword?/totalBeforeFilter?", "methodsOmitted?/omittedMethods?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
233
- notes: ["url 恒在(configJson.url;DATA_SQL/DATA_TABLE/SAP/KAFKA/INTERNAL 回 null,不是缺键)——name 是人工显示名,语义可能与 url 相反,判「打到哪个接口」只认 url;detail:true 把 inParams/outParams 从计数换成参数 code 数组(0 额外 wire)"],
243
+ keys: ["status", "serviceCode", "adapterCode", "present", "methodsCount", "columnNote", "referencedNote", "methods:array<{code,name,url,httpType,requestBodyType,inParams,outParams,configKeys,referenced}>", "keyword?/totalBeforeFilter?", "methodsOmitted?/omittedMethods?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
244
+ notes: ["url 恒在(configJson.url;DATA_SQL/DATA_TABLE/SAP/KAFKA/INTERNAL 回 null,不是缺键)——name 是人工显示名,语义可能与 url 相反,判「打到哪个接口」只认 url;referenced 来自平台 bizMethodMapping 计数(filterFlag=false 同样置位——F14 真机钉死),只覆盖规则图映射,删方法前用 rule.references kind=service 复核;detail:true 把 inParams/outParams 从计数换成参数 code 数组(0 额外 wire)"],
234
245
  },
235
246
  "service.adapter_config": {
236
247
  // r28f F5:顶栏 adapterCodes 摘要;compact:true 只回 code/name/description。
@@ -319,4 +330,12 @@ const READ_SHAPES = {
319
330
  export function readShapeFor(toolName) {
320
331
  return READ_SHAPES[toolName];
321
332
  }
333
+ /**
334
+ * A2(r89 契约层):`resultMeta.locator` 投影——信封侧元数据,键名对照表由
335
+ * read-shapes 单一声明。没有 locator 的工具零字节。
336
+ */
337
+ export function locatorMetaFor(toolName) {
338
+ const locator = READ_SHAPES[toolName]?.locator;
339
+ return locator === undefined ? undefined : { locator };
340
+ }
322
341
  //# sourceMappingURL=read-shapes.js.map
package/dist/rollback.js CHANGED
@@ -11,6 +11,7 @@ import { emitTransportResult, emitInvalid } from "./command-transport.js";
11
11
  import { acquireWriteLock } from "./write-lock.js";
12
12
  import { resolveSinceRef } from "./duration.js";
13
13
  import { normalizeWriteReason } from "./write-audit.js";
14
+ import { appendBatchAuditLine, executeGovernedBatch } from "./batch-executor.js";
14
15
  /** Invalid `--since`: the CLI maps it to invalid-input (exit 10), never a guessed window. */
15
16
  export class SinceRefError extends Error {
16
17
  }
@@ -262,28 +263,74 @@ export async function applyRollback(ref, options, context) {
262
263
  }
263
264
  await new Promise((resolve) => setTimeout(resolve, Math.min(200, Math.max(0, deadline - Date.now()))));
264
265
  }
266
+ let progressFile;
267
+ let batchSteps = [];
265
268
  try {
266
- for (const [index, call] of plan.inverse.calls.entries()) {
267
- const { exitCode, result } = await runToolCall(call.tool, {
268
- args: { ...call.args, environment: entry.environment, ...(options.confirmProduction ? { confirmProduction: true } : {}) },
269
- requestId: `omc-rollback-${entry.seq}-${index + 1}`,
270
- context: ctx,
271
- reason: restoreReason,
272
- print: () => undefined,
273
- });
274
- results.push({
275
- tool: call.tool,
276
- exitCode,
277
- status: result.status,
278
- ...(result.deliveryState ? { deliveryState: result.deliveryState } : {}),
279
- ...(result.summary ? { summary: result.summary } : {}),
280
- // r55: exit-code-only results hid the reason a restore call failed
281
- // (input-invalid showed as a bare "status=error"). Surface the shape.
282
- ...(exitCode === 0 ? {} : { blocker: result.blocker ?? null, message: result.message ?? null, ...(result.issues !== undefined ? { issues: result.issues } : {}), ...(result.diagnostic !== undefined ? { diagnostic: result.diagnostic } : {}) }),
283
- });
284
- if (exitCode !== 0)
285
- return { status: "stopped", rollbackOf: { seq: entry.seq, tool: entry.tool }, step: index + 1, results, message: `恢复调用 ${call.tool} 未成功(status=${result.status});已执行的调用已各自记 journal,可对已完成步骤再 plan` };
269
+ // B1:执行段(串行/首败即停/超时冻结/progressFile)由共享 governed batch
270
+ // executor 承担;本面只负责「怎么重放一次恢复调用」(真实 tool handler +
271
+ // 每次 requestId)和把结果投影回旧回执字段(results/step/status 逐字不变)。
272
+ const executed = await executeGovernedBatch({
273
+ changes: plan.inverse.calls.map((call) => ({ tool: call.tool, args: call.args })),
274
+ mode: "rollback",
275
+ progress: { ctx, summary: restoreReason },
276
+ runTool: async (call, index) => {
277
+ const { exitCode, result } = await runToolCall(call.tool, {
278
+ args: { ...call.args, environment: entry.environment, ...(options.confirmProduction ? { confirmProduction: true } : {}) },
279
+ requestId: `omc-rollback-${entry.seq}-${index + 1}`,
280
+ context: ctx,
281
+ reason: restoreReason,
282
+ print: () => undefined,
283
+ });
284
+ results.push({
285
+ tool: call.tool,
286
+ exitCode,
287
+ status: result.status,
288
+ ...(result.deliveryState ? { deliveryState: result.deliveryState } : {}),
289
+ ...(result.summary ? { summary: result.summary } : {}),
290
+ // r55: exit-code-only results hid the reason a restore call failed
291
+ // (input-invalid showed as a bare "status=error"). Surface the shape.
292
+ ...(exitCode === 0 ? {} : { blocker: result.blocker ?? null, message: result.message ?? null, ...(result.issues !== undefined ? { issues: result.issues } : {}), ...(result.diagnostic !== undefined ? { diagnostic: result.diagnostic } : {}) }),
293
+ });
294
+ if (exitCode !== 0)
295
+ return {
296
+ kind: "stop",
297
+ status: "refused",
298
+ envelope: { message: `恢复调用 ${call.tool} 未成功(status=${result.status});已执行的调用已各自记 journal,可对已完成步骤再 plan` },
299
+ };
300
+ // Same identity projection as apply_changes/intent receipts (step/index/
301
+ // status); the rollback-specific evidence stays in `results[]` below.
302
+ return { kind: "ok", step: { step: call.tool, index, status: result.status } };
303
+ },
304
+ });
305
+ if (executed.kind === "stop") {
306
+ const outcome = executed.outcome;
307
+ // A failed replay call is the legacy "stopped" verdict (exit 1); the
308
+ // executor's own `refused` is its internal classification. A budget /
309
+ // transport freeze stays `uncertain` — never success.
310
+ return {
311
+ status: outcome.status === "uncertain" ? "uncertain" : "stopped",
312
+ rollbackOf: { seq: entry.seq, tool: entry.tool },
313
+ step: outcome.failedStep.index + 1,
314
+ ...outcome.envelope,
315
+ results,
316
+ steps: outcome.steps,
317
+ failedStep: outcome.failedStep,
318
+ };
286
319
  }
320
+ // Delivered restore batch → one honest `rollbackable:false` audit line
321
+ // (B1/W11C), discoverable with `omc rollback list --tool rollback`. The
322
+ // per-call restore writes were already journaled by their own handlers.
323
+ await appendBatchAuditLine({
324
+ ctx,
325
+ mode: "rollback",
326
+ environmentArg: entry.environment,
327
+ reason: restoreReason,
328
+ steps: executed.steps,
329
+ rollbackOf: { seq: entry.seq, tool: entry.tool },
330
+ progressFile: executed.progressFile,
331
+ });
332
+ progressFile = executed.progressFile;
333
+ batchSteps = executed.steps;
287
334
  }
288
335
  finally {
289
336
  await lock.release();
@@ -310,6 +357,9 @@ export async function applyRollback(ref, options, context) {
310
357
  status: "ok",
311
358
  rollbackOf: { seq: entry.seq, tool: entry.tool, target: entry.target },
312
359
  calls: results,
360
+ // B1: the shared step-identity projection (same shape as apply_changes /
361
+ // intent receipts); the per-call evidence stays in `calls[]`.
362
+ steps: batchSteps,
313
363
  verify,
314
364
  // R88 #3:恢复写落 journal 时记的 reason(journal 是唯一审计真相源)。
315
365
  reason: restoreReason,
@@ -319,6 +369,7 @@ export async function applyRollback(ref, options, context) {
319
369
  restoredSha256: restoredSha,
320
370
  matchesBefore: verify === "restored",
321
371
  recoveredTo: { seq: entry.seq, ts: entry.ts },
372
+ ...(progressFile !== undefined ? { progressFile } : {}),
322
373
  ...(verify === "mismatch" ? { beforeSha, restoredSha, message: "恢复调用已完成但读回与 before 存在值冲突(非默认显式化):立即人工核对目标现态(omc rollback plan <seq> 的 diff 可复看差异)" } : {}),
323
374
  hint: "本次恢复的每次调用都走了完整写闸门并已记 journal;恢复本身可再回滚(rollback plan <新 seq>)",
324
375
  };
@@ -1475,7 +1475,47 @@ async function verifyRulePublish(session, schemaCode, ruleCode, publishResponse)
1475
1475
  },
1476
1476
  };
1477
1477
  }
1478
- export async function executeRuleSaveWrite(session, args) {
1478
+ /**
1479
+ * A4(r89 契约层):rule 族统一状态段 `ruleStatus`——三个写入口(rule.save 整图 /
1480
+ * rule.node.update 单节点 patch / configure_rule+rule.enable 保存并启用)与
1481
+ * 「保存≠启用、启用≠发布面」的平台事实一仔回执拼写:
1482
+ *
1483
+ * { operation:"save|patch|save-enable",
1484
+ * target:{schemaCode, ruleCode, nodeCode?},
1485
+ * graph:{saved, nodes},
1486
+ * activation:{published?, enabled?} }
1487
+ *
1488
+ * 平台事实(file:line):
1489
+ * - 保存只写 DRAFT 行,发布才铸 PUBLISH 版本:BusinessRuleFacadeImpl
1490
+ * .publishBusinessRule:337-352(updateBusinessRule 后 businessRuleService.publish
1491
+ * 铸新 ruleVersion)。
1492
+ * - 运行时门读 **DRAFT 行** enabled+status,且要求已发布版本存在:
1493
+ * BusinessRuleTableImpl.getExecutableBySchemaCodeAndCode:83-100(:88 !enabled 或
1494
+ * DISABLED → null;:91-94 无 latestPublished 行 → null)。保存≠启用≠发布。
1495
+ * - 应用列表面服务 DRAFT 行(BusinessRuleFacadeImpl.listViewsBySchemaCode:143-150
1496
+ * → listDraftBySchemaCode);runtime 列表面投影 PUBLISH 行
1497
+ * (BusinessRuleFacadeImpl.listLatestRulesBySchemaCode:153-156;
1498
+ * BusinessRuleRuntimeController.list:71-77)——两面 enabled 语义不同。
1499
+ * - enable 翻 DRAFT 行 status:BusinessRuleController.enable:445-465
1500
+ * (getBusinessRuleOfDraft + changeStatus(ENABLED);已 ENABLED 回
1501
+ * BUSINESS_RULE_ALREADY_ENABLED)。
1502
+ */
1503
+ export function ruleStatusSegment(input) {
1504
+ return {
1505
+ operation: input.operation,
1506
+ target: { schemaCode: input.schemaCode, ruleCode: input.ruleCode, ...(input.nodeCode !== undefined ? { nodeCode: input.nodeCode } : {}) },
1507
+ graph: { saved: input.saved, nodes: input.nodes, ...(input.graphNote !== undefined ? { note: input.graphNote } : {}) },
1508
+ ...(input.published !== undefined || input.enabled !== undefined
1509
+ ? {
1510
+ activation: {
1511
+ ...(input.published !== undefined ? { published: input.published } : {}),
1512
+ ...(input.enabled !== undefined ? { enabled: input.enabled } : {}),
1513
+ },
1514
+ }
1515
+ : {}),
1516
+ };
1517
+ }
1518
+ export async function executeRuleSaveWrite(session, args, origin = { operation: "save" }) {
1479
1519
  // 与 dry-run 同源:同一套只读门先跑,然后才写。
1480
1520
  const { lintWarnings, lintHazards, bizMethodChecks, existing, customTriggerApplied, isPresetRule, bizRuleType, nodeJson, routeJson, schedulerField, schedulerSetting, nodes, routesSource, emptyMappings, preservedDesignerText, designerTextOverwritten, mappingFieldChecks, absentMappingFields, } = await lintRuleSaveWrite(session, args);
1481
1521
  // r85(retro 2026-11-19):dry-run 与真写共用的回执增量(routes 沿用 / 空映射 /
@@ -1580,6 +1620,7 @@ export async function executeRuleSaveWrite(session, args) {
1580
1620
  const previousRuleVersion = existing?.ruleVersion;
1581
1621
  return {
1582
1622
  performed: { errcode: performed.errcode, mode: existing?.id ? "update" : "create", publishRequested: true, ...(bizMethodChecks > 0 ? { bizMethodChecks } : {}) },
1623
+ ruleStatus: ruleStatusSegment({ operation: origin.operation, schemaCode: args.schemaCode, ruleCode: args.ruleCode, ...(origin.nodeCode !== undefined ? { nodeCode: origin.nodeCode } : {}), saved: true, nodes: nodes.length, published, enabled }),
1583
1624
  readback: {
1584
1625
  rulePresent: true,
1585
1626
  published,
@@ -1623,6 +1664,7 @@ export async function executeRuleSaveWrite(session, args) {
1623
1664
  const previousRuleVersion = existing?.ruleVersion;
1624
1665
  return {
1625
1666
  performed: { errcode: performed.errcode, mode: existing?.id ? "update" : "create", ...(bizMethodChecks > 0 ? { bizMethodChecks } : {}) },
1667
+ ruleStatus: ruleStatusSegment({ operation: origin.operation, schemaCode: args.schemaCode, ruleCode: args.ruleCode, ...(origin.nodeCode !== undefined ? { nodeCode: origin.nodeCode } : {}), saved: true, nodes: nodes.length, published: false, enabled }),
1626
1668
  readback: {
1627
1669
  rulePresent: true,
1628
1670
  published: false,
@@ -0,0 +1,57 @@
1
+ /**
2
+ * A5 (r89 契约层) — one unified receipt segment for every biz-service write
3
+ * entry: `service.register` / `service.update` / `method.create` /
4
+ * `method.update` / `method.delete`. The TOOLS stay separate (no merged write
5
+ * surface); only the "what did I just do, and what is the authoritative state"
6
+ * projection is shared — the same shape as `ruleStatusSegment`
7
+ * (rule-support.ts) does for the rule family.
8
+ *
9
+ * Every segment answers, in one place:
10
+ * - which operation ran and on what (service + optional method),
11
+ * - whether the service/method is present after the write,
12
+ * - whether a declared parameter face was verified against the readback.
13
+ * The historical `readback` keys are untouched (additive only).
14
+ */
15
+ /** Single constructor of the `serviceStatus` top-level segment (write.ts passes it through). */
16
+ export function serviceStatusSegment(input) {
17
+ const { operation, serviceCode, methodCode, servicePresent, methodPresent, parameterFaceVerified } = input;
18
+ return {
19
+ operation,
20
+ target: { serviceCode, ...(methodCode !== undefined ? { methodCode } : {}) },
21
+ service: { present: servicePresent },
22
+ ...(methodCode !== undefined && methodPresent !== undefined ? { method: { present: methodPresent } } : {}),
23
+ ...(parameterFaceVerified !== undefined ? { parameterFaceVerified } : {}),
24
+ };
25
+ }
26
+ /** Parameter codes of a declared/stored parameter face (array, or a JSON string column). */
27
+ function parameterCodes(face) {
28
+ let value = face;
29
+ if (typeof value === "string") {
30
+ try {
31
+ value = JSON.parse(value);
32
+ }
33
+ catch {
34
+ return [];
35
+ }
36
+ }
37
+ if (!Array.isArray(value))
38
+ return [];
39
+ return value
40
+ .filter((entry) => Boolean(entry && typeof entry === "object" && !Array.isArray(entry)))
41
+ .map((entry) => (typeof entry.code === "string" ? entry.code : ""))
42
+ .filter((code) => code !== "");
43
+ }
44
+ /**
45
+ * Did the declared parameter face survive the write verbatim? Every declared
46
+ * code must appear on the stored face (extra platform-injected parameters are
47
+ * expected and do not fail the check). `undefined` declared face → not
48
+ * applicable, callers omit the flag instead of claiming a verification.
49
+ */
50
+ export function parameterFaceCovers(stored, declared) {
51
+ const wanted = parameterCodes(declared);
52
+ if (wanted.length === 0)
53
+ return true;
54
+ const actual = new Set(parameterCodes(stored));
55
+ return wanted.every((code) => actual.has(code));
56
+ }
57
+ //# sourceMappingURL=service-support.js.map
@@ -0,0 +1,37 @@
1
+ import { firstCallCommandFor, placeholderSourceFor, requiredArgs, shapeRefFor } from "./discovery.js";
2
+ /** 组包一份 surfaceRef;工具不在 registry 时返回 undefined(调用面零字节)。 */
3
+ export function surfaceRefFor(registry, toolName, options = {}) {
4
+ const tool = registry.find((entry) => entry.name === toolName);
5
+ if (tool === undefined)
6
+ return undefined;
7
+ const required = requiredArgs(tool);
8
+ const argsHint = required.length === 0 ? "{}" : required.join(",");
9
+ const firstCall = firstCallCommandFor(tool);
10
+ const recipe = tool.executionMetadata?.recipes?.find((entry) => entry.id === firstCall?.recipeId) ?? tool.executionMetadata?.recipes?.[0];
11
+ const missing = firstCall?.missing ?? [];
12
+ const needs = missing
13
+ .map((name) => ({ name, resolve: placeholderSourceFor(name) ?? "按 inputSchema 或任务要求" }))
14
+ .filter((need) => need.resolve !== "按 inputSchema 或任务要求" || need.name === "environment");
15
+ const onRefusal = (recipe?.refusalRecovery ?? [])
16
+ .slice(0, 3)
17
+ .map((entry) => ({ code: String(entry.code ?? ""), next: String(entry.action ?? "") }))
18
+ .filter((entry) => entry.code !== "" && entry.next !== "");
19
+ return {
20
+ recommended: { tool: tool.name, argsHint, ...(options.via !== undefined ? { via: options.via } : {}) },
21
+ ...(options.alternatives !== undefined && options.alternatives.length > 0 ? { alternatives: options.alternatives } : {}),
22
+ ...(firstCall !== undefined
23
+ ? {
24
+ firstCall: {
25
+ recipeId: firstCall.recipeId,
26
+ ...(firstCall.command !== undefined ? { command: firstCall.command } : {}),
27
+ ...(firstCall.commandHint !== undefined ? { commandHint: firstCall.commandHint } : {}),
28
+ ...(missing.length > 0 ? { missing } : {}),
29
+ },
30
+ }
31
+ : {}),
32
+ ...(needs.length > 0 ? { needs } : {}),
33
+ ...(shapeRefFor(tool.name) !== undefined ? { returns: shapeRefFor(tool.name) } : {}),
34
+ ...(onRefusal.length > 0 ? { onRefusal } : {}),
35
+ };
36
+ }
37
+ //# sourceMappingURL=surface-ref.js.map
package/dist/write.js CHANGED
@@ -190,7 +190,7 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
190
190
  const artifactRef = writeArtifact(ctx, `${tool.name}-${randomUUID().slice(0, 8)}.json`, artifact);
191
191
  return { status: executed.status, steps: executed.steps, failedStep: executed.failedStep, ...executed.envelope, ...(args.requestId ? { requestId: args.requestId } : {}), artifactFingerprint: artifactRef.detailSha256 };
192
192
  }
193
- const { performed, readback, steps, halfSuccess, irreversible, rollbackReceipt, runtimeVerification } = executed;
193
+ const { performed, readback, steps, halfSuccess, irreversible, rollbackReceipt, runtimeVerification, ruleStatus, serviceStatus } = executed;
194
194
  // Readback gate (live 2026-10-17): a tool that reports `readback.present:false`
195
195
  // has NOT proven its own write — the platform accepted the request but the
196
196
  // object is absent from the authoritative face. "Called without error" must
@@ -207,6 +207,8 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
207
207
  performed,
208
208
  readback,
209
209
  ...(steps !== undefined ? { steps } : {}),
210
+ ...(ruleStatus !== undefined ? { ruleStatus } : {}),
211
+ ...(serviceStatus !== undefined ? { serviceStatus } : {}),
210
212
  ...(productionConfirmed ? { productionConfirmed: true } : {}),
211
213
  ...(reason !== undefined ? { reason } : {}),
212
214
  ...(tool.rollback
@@ -259,6 +261,8 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
259
261
  ...(readOnlyEscapeNote !== undefined ? { readOnlyEscape: readOnlyEscapeNote } : {}),
260
262
  performed,
261
263
  readback,
264
+ ...(ruleStatus !== undefined ? { ruleStatus } : {}),
265
+ ...(serviceStatus !== undefined ? { serviceStatus } : {}),
262
266
  ...(readbackWarning ? { readbackWarning } : {}),
263
267
  ...(steps !== undefined ? { steps } : {}),
264
268
  ...(halfSuccess !== undefined ? { halfSuccess } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.86",
3
+ "version": "0.6.87",
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.86",
59
+ "omc-core": "0.6.87",
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.86"
77
+ "@stalfh233/omc-fake-platform": "0.6.87"
78
78
  }
79
79
  }
@@ -192,7 +192,7 @@ only the section for the capability you need —
192
192
  - **能做哪些事**:业务服务与方法注册(RESTFUL/DATA_SQL/DATA_TABLE/SAP/KAFKA/SOAP)、服务清单(按分类/关键词,凭据不回显)、方法增改删、分类/连接池、导入导出、设计器测试、调用日志(`h_log_biz_service`:params/result/状态/耗时,按单据/服务/方法/时间窗查,无过滤 fail-closed)。
193
193
  - **工具**:`service.list`、`service.get`、`method.list`、`method.get`、`method.update`、`method.create`、`method.delete`、`service.category.list`、`service.category.create`、`service.category.update`、`service.category.delete`、`service.dbconnpool.list`、`service.dbconnpool.create`、`service.dbconnpool.update`、`service.dbconnpool.delete`、`service.adapter_config`、`service.table_list`、`service.table_sql`、`service.register`、`service.update`、`service.delete`、`service.export`、`service.check`、`service.import`、`method.test`、`servicelog.search`
194
194
  - **recipe**:`omc describe service.register --example restful-query-service`
195
- - **intent**:`services[].method`(单方法,name==code)与 `services[].methods[]`(多方法,name 可不同于 code)互斥;`methods[]` 对缺失方法 plan `method.create`、漂移 plan `method.update`,因此给既有服务加方法无需 escape hatch。
195
+ - **intent**:`services[].method`(单方法,name==code)与 `services[].methods[]`(多方法,name 可不同于 code)互斥;`methods[]` 对缺失方法 plan `method.create`、漂移 plan `method.update`,因此给既有服务加方法无需 escape hatch。删除:`services[].absent:true`(只认 code;平台级联删方法,plan 只发 `service.delete`;服务仍被规则映射引用 → plan 硬拒 `intent-service-referenced`,先解绑规则再删)与 `method(s)[].absent:true`(平台被引用回 500108,plan 给 `method-referenced` warning,带 ruleCode/nodeCode 引用点)。
196
196
  - **边界 / 陷阱**:方法 `configJson` 走 AES-128-ECB;**二开接口 = 扩展模块写 REST 接口 + RESTFUL 服务指向它**(页面/规则引用);RESTFUL/DATA_SQL 绑定前须带适配器必需配置(否则是注册壳)。排查「规则到底传了什么参数给接口」用 `servicelog.search`(`bizObjectId`/`schemaCode` 是客户端匹配,`code`/`methodName` 为 LIKE 包含、逗号=精确 IN;params 平台入库上限 2000 字符)。
197
197
 
198
198
  ## 报表 `report`