@stalfh233/omc-cli 0.6.83 → 0.6.85

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.
@@ -8,6 +8,7 @@ import { writeTool } from "../write.js";
8
8
  import { registerPackageTool } from "../package-tool.js";
9
9
  import { writeSummary } from "../human-summary.js";
10
10
  import { defineTool, ToolInputError } from "../tool-types.js";
11
+ import { DEFAULT_SCAN_CONCURRENCY, mapWithConcurrency } from "../concurrency.js";
11
12
  import { wireCall, wireRows, WireError } from "../wire.js";
12
13
  import { diagnoseInstanceActivity, getInstanceBaseInfo, listInstanceActivities, listWorkItemsByParticipant, resolveBizObjectIdByInstance, searchWorkItems, wireString } from "../workflow-support.js";
13
14
  import { readSchemaFormButtons } from "../form-support.js";
@@ -2175,7 +2176,7 @@ async function mergedTemplateBody(session, schemaCode, code, template, merge = f
2175
2176
  * readback must treat them as "no workflow" so workflow.create can proceed
2176
2177
  * instead of stopping at the probe's 401001.
2177
2178
  */
2178
- function isWorkflowAbsent(error) {
2179
+ export function isWorkflowAbsent(error) {
2179
2180
  return error instanceof WireError && error.kind === "business" && error.errcode === 401001;
2180
2181
  }
2181
2182
  /**
@@ -2183,7 +2184,7 @@ function isWorkflowAbsent(error) {
2183
2184
  * workflow it backs via the platform link (workflow/isworkflow →
2184
2185
  * workflow/getWorkflow); return null when the model has no workflow.
2185
2186
  */
2186
- async function resolveWorkflowArg(session, args) {
2187
+ export async function resolveWorkflowArg(session, args) {
2187
2188
  if (args.workflowCode)
2188
2189
  return args.workflowCode;
2189
2190
  if (!args.schemaCode)
@@ -2228,7 +2229,7 @@ async function getWorkflowHeaderOrNull(session, workflowCode) {
2228
2229
  throw error;
2229
2230
  }
2230
2231
  }
2231
- async function getWorkflowDraftOrNull(session, workflowCode) {
2232
+ export async function getWorkflowDraftOrNull(session, workflowCode) {
2232
2233
  try {
2233
2234
  return ((await wireCall(session, { path: ENDPOINTS.workflowGetDraft, query: { workflowCode } })).data ?? null);
2234
2235
  }
@@ -2448,14 +2449,31 @@ export function workflowCompactProjection(result) {
2448
2449
  */
2449
2450
  function effectiveActivityName(activity) {
2450
2451
  const i18n = activity.name_i18n;
2451
- if (i18n && typeof i18n === "object") {
2452
- const map = i18n;
2452
+ // The rename carrier is normally a locale MAP, but some platform families
2453
+ // answer it as a JSON STRING of that map (observed on a 1.1.x-compat
2454
+ // endpoint: i18nMessage gets the new name, name_i18n comes back stringified).
2455
+ // Without parsing it, a renamed node keeps reading its first-created
2456
+ // activityName and every draft↔published diff would miss the rename.
2457
+ const map = typeof i18n === "string" ? parseLocalizedMap(i18n) : i18n && typeof i18n === "object" ? i18n : undefined;
2458
+ if (map !== undefined) {
2453
2459
  const localized = map.zh ?? map.zh_TW ?? map.en;
2454
2460
  if (localized !== undefined && String(localized) !== "")
2455
2461
  return String(localized);
2456
2462
  }
2457
2463
  return (activity.activityName ?? activity.i18nMessage ?? null);
2458
2464
  }
2465
+ function parseLocalizedMap(value) {
2466
+ const trimmed = value.trim();
2467
+ if (!trimmed.startsWith("{"))
2468
+ return undefined;
2469
+ try {
2470
+ const parsed = JSON.parse(trimmed);
2471
+ return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
2472
+ }
2473
+ catch {
2474
+ return undefined;
2475
+ }
2476
+ }
2459
2477
  /**
2460
2478
  * A workflow event handler (start/cancel/activate/end) binds a business rule by
2461
2479
  * CODE. The platform's designer rule picker only offers CUSTOM rules — the
@@ -2529,6 +2547,81 @@ async function ensureWorkflowRulesEnabled(session, schemaCode, codes, byCode) {
2529
2547
  }
2530
2548
  return { enabledRuleCodes, alreadyEnabledRuleCodes };
2531
2549
  }
2550
+ /** 该 target(flow 级 handler / node 级事件)在模板上的 handler 对象。 */
2551
+ function bindTargetHandlerOf(template, target) {
2552
+ if (target.scope === "workflow")
2553
+ return (template?.[target.field] ?? {}) ?? {};
2554
+ return (findTemplateActivity(template, target.activityCode)?.[target.field] ?? {}) ?? {};
2555
+ }
2556
+ /**
2557
+ * unbindRule 的读回+校验上下文——execute 与 dryRunPayload **共用这一个函数**
2558
+ * (同 rule.node.update 的 loadRuleNodePatchGraph 模式),保证 dry-run 与真写
2559
+ * 对「不存在流程 / 不存在活动 / absent code」给出完全相同的 refusal:此前
2560
+ * dry-run 走 write.ts 的泛型 plan 信封,打错 ruleCode 也回 wouldChange:true,
2561
+ * 真写才拒 absent。本函数只读草稿 + 本地校验(含模板渲染检查),零写入。
2562
+ */
2563
+ async function unbindRuleContext(session, args) {
2564
+ const target = resolveBindTarget(args.handler, args.nodeEvent, args.activityCode);
2565
+ const codes = (args.ruleCodes ?? [args.ruleCode]).map(String);
2566
+ const shouldPublish = args.publish !== false;
2567
+ const draft = (await getWorkflowDraftOrNull(session, args.workflowCode)) ?? {};
2568
+ if (Object.keys(draft).length === 0) {
2569
+ throw new ToolRefusalError({
2570
+ status: "refused",
2571
+ blocker: "workflow-not-found",
2572
+ workflowCode: args.workflowCode,
2573
+ message: `流程 ${args.workflowCode} 不存在(get_draft 401001 缺席)——先 workflow.create,再 unbindRule`,
2574
+ });
2575
+ }
2576
+ if (target.scope === "activity" && !findTemplateActivity(draft, target.activityCode)) {
2577
+ throw new ToolRefusalError({
2578
+ status: "refused",
2579
+ blocker: "workflow-activity-not-found",
2580
+ workflowCode: args.workflowCode,
2581
+ activityCode: target.activityCode,
2582
+ activities: templateActivityCodes(draft),
2583
+ message: `流程 ${args.workflowCode} 的草稿里没有活动 ${target.activityCode}——节点级事件必须指向已存在的活动。可用活动:${templateActivityCodes(draft).join("、") || "(无)"}(先用 workflow.get_draft 看 code,别用节点名)`,
2584
+ });
2585
+ }
2586
+ const existing = bindTargetHandlerOf(draft, target);
2587
+ const priorActions = Array.isArray(existing.bizActions)
2588
+ ? existing.bizActions.filter((value) => typeof value === "string")
2589
+ : [];
2590
+ // Fail closed BEFORE any wire call when the caller names codes the handler
2591
+ // does not carry — a typo'd ruleCode must not report a phantom success,
2592
+ // and the existing codes are the fix's raw material.
2593
+ const absent = codes.filter((code) => !priorActions.includes(code));
2594
+ if (absent.length > 0) {
2595
+ throw new ToolRefusalError({
2596
+ status: "refused",
2597
+ blocker: "workflow-unbind-rule-absent",
2598
+ workflowCode: args.workflowCode,
2599
+ absentRuleCodes: absent,
2600
+ bizActions: priorActions,
2601
+ ...(target.scope === "activity" ? { activityCode: target.activityCode, nodeEvent: target.key } : { handler: target.key }),
2602
+ message: `该处理器当前没有绑定 ${absent.join("、")}——现有绑定:${priorActions.join("、") || "(无)"}。解绑只对已绑定的 code 生效;要换目标先看 workflow.get_draft 的 ruleBindings/nodeRuleBindings`,
2603
+ });
2604
+ }
2605
+ const nextActions = priorActions.filter((code) => !codes.includes(code));
2606
+ // 移空后的写回形状按平台 canonical 未绑态:handler 对象保留、bizActions 与
2607
+ // bizActionType 置 null(WorkflowTemplateController 的模板示例即此形状;平台
2608
+ // 判空走 CollectionUtils.isEmpty,null 与 [] 等价,null 是平台自己的存量拼写)。
2609
+ const mergedHandler = nextActions.length > 0
2610
+ ? { ...(typeof existing === "object" && existing ? existing : {}), bizActions: nextActions, bizActionType: "BIZ_RULE" }
2611
+ : { ...(typeof existing === "object" && existing ? existing : {}), bizActions: null, bizActionType: null };
2612
+ let nextTemplate;
2613
+ if (target.scope === "workflow") {
2614
+ nextTemplate = { ...draft, [target.field]: mergedHandler, workflowCode: args.workflowCode, schemaCode: args.schemaCode };
2615
+ }
2616
+ else {
2617
+ // Keep the draft's activities container shape (array or index-keyed
2618
+ // object) — only the selected row's handler field changes.
2619
+ nextTemplate = mapTemplateActivity(draft, target.activityCode, (row) => ({ ...row, [target.field]: mergedHandler })).template;
2620
+ nextTemplate = { ...nextTemplate, workflowCode: args.workflowCode, schemaCode: args.schemaCode };
2621
+ }
2622
+ validateWorkflowRender(nextTemplate, "workflow.unbindRule");
2623
+ return { target, codes, shouldPublish, nextTemplate, priorActions, nextActions };
2624
+ }
2532
2625
  export function registerWorkflowLane(tools) {
2533
2626
  // Sibling registry for the high-level `configure_workflow` (reuses each atomic
2534
2627
  // tool's own writeExecute so every gate + readback is identical).
@@ -2598,32 +2691,36 @@ export function registerWorkflowLane(tools) {
2598
2691
  }
2599
2692
  const capped = totalModels > WORKFLOW_LIST_MODEL_CAP;
2600
2693
  const scanRows = capped ? modelRows.slice(0, WORKFLOW_LIST_MODEL_CAP) : modelRows;
2694
+ // R88 提案 #2:模型级并发扫描(默认 4,direct-handoff 信号量)。回执按
2695
+ // scanRows 原序重组——与串行基线逐字段一致,并发完成顺序不抖动输出;
2696
+ // 单模型读失败仍落 readFailed 行(partial 语义不变);限流类错误一次
2697
+ // 抖动退避重试,仍失败把后续窗口降到 2(wire.concurrency 如实标注)。
2698
+ const scan = await mapWithConcurrency(scanRows, DEFAULT_SCAN_CONCURRENCY, (row) => scanModelWorkflowBindings(session, String(row.code)));
2601
2699
  const workflows = [];
2602
2700
  let withWorkflow = 0;
2603
2701
  let publishedCount = 0;
2604
2702
  let absentCount = 0;
2605
2703
  let readFailures = 0;
2606
- for (const row of scanRows) {
2607
- const modelCode = String(row.code);
2608
- try {
2609
- const face = await scanModelWorkflowBindings(session, modelCode);
2610
- if (face === null) {
2611
- absentCount += 1;
2612
- workflows.push({ modelCode, workflowCode: null, exists: false, published: false, ruleBindingCount: 0 });
2613
- continue;
2614
- }
2615
- withWorkflow += 1;
2616
- if (face.published)
2617
- publishedCount += 1;
2618
- workflows.push({ modelCode, workflowCode: face.workflowCode, exists: true, published: face.published, ruleBindingCount: face.ruleBindingCount });
2619
- }
2620
- catch {
2704
+ scan.outcomes.forEach((outcome, index) => {
2705
+ const modelCode = String(scanRows[index].code);
2706
+ if (!outcome.ok) {
2621
2707
  // 单模型读失败不中断整轮清单;行级 readFailed 标注,不让一次失败
2622
2708
  // 变成整面错误(同 participantSearch 的容错口径)。
2623
2709
  readFailures += 1;
2624
2710
  workflows.push({ modelCode, workflowCode: null, exists: null, published: null, ruleBindingCount: null, readFailed: true });
2711
+ return;
2625
2712
  }
2626
- }
2713
+ const face = outcome.value;
2714
+ if (face === null) {
2715
+ absentCount += 1;
2716
+ workflows.push({ modelCode, workflowCode: null, exists: false, published: false, ruleBindingCount: 0 });
2717
+ return;
2718
+ }
2719
+ withWorkflow += 1;
2720
+ if (face.published)
2721
+ publishedCount += 1;
2722
+ workflows.push({ modelCode, workflowCode: face.workflowCode, exists: true, published: face.published, ruleBindingCount: face.ruleBindingCount });
2723
+ });
2627
2724
  return {
2628
2725
  applicationResolution: { ...applicationResolutionOf(scope), models: totalModels },
2629
2726
  modelsCount: totalModels,
@@ -2633,7 +2730,10 @@ export function registerWorkflowLane(tools) {
2633
2730
  absentCount,
2634
2731
  ...(readFailures > 0 ? { readFailures } : {}),
2635
2732
  workflows,
2636
- wire: { plan: "1 应用树 + 每模型 isworkflow(无流程即止,1 wire)→ 有流程再 getWorkflow + get_published(共 3 wire)" },
2733
+ wire: {
2734
+ plan: "1 应用树 + 每模型 isworkflow(无流程即止,1 wire)→ 有流程再 getWorkflow + get_published(共 3 wire)",
2735
+ concurrency: scan.stats,
2736
+ },
2637
2737
  ...(capped
2638
2738
  ? {
2639
2739
  partial: true,
@@ -3278,70 +3378,9 @@ export function registerWorkflowLane(tools) {
3278
3378
  publish: z.boolean().optional(),
3279
3379
  },
3280
3380
  execute: async (session, args) => {
3281
- const target = resolveBindTarget(args.handler, args.nodeEvent, args.activityCode);
3282
- const codes = (args.ruleCodes ?? [args.ruleCode]).map(String);
3283
- const shouldPublish = args.publish !== false;
3284
- const draft = (await getWorkflowDraftOrNull(session, args.workflowCode)) ?? {};
3285
- if (Object.keys(draft).length === 0) {
3286
- throw new ToolRefusalError({
3287
- status: "refused",
3288
- blocker: "workflow-not-found",
3289
- workflowCode: args.workflowCode,
3290
- message: `流程 ${args.workflowCode} 不存在(get_draft 401001 缺席)——先 workflow.create,再 unbindRule`,
3291
- });
3292
- }
3293
- if (target.scope === "activity" && !findTemplateActivity(draft, target.activityCode)) {
3294
- throw new ToolRefusalError({
3295
- status: "refused",
3296
- blocker: "workflow-activity-not-found",
3297
- workflowCode: args.workflowCode,
3298
- activityCode: target.activityCode,
3299
- activities: templateActivityCodes(draft),
3300
- message: `流程 ${args.workflowCode} 的草稿里没有活动 ${target.activityCode}——节点级事件必须指向已存在的活动。可用活动:${templateActivityCodes(draft).join("、") || "(无)"}(先用 workflow.get_draft 看 code,别用节点名)`,
3301
- });
3302
- }
3303
- const handlerOf = (template) => {
3304
- if (target.scope === "workflow")
3305
- return (template?.[target.field] ?? {}) ?? {};
3306
- return (findTemplateActivity(template, target.activityCode)?.[target.field] ?? {}) ?? {};
3307
- };
3308
- const existing = handlerOf(draft);
3309
- const priorActions = Array.isArray(existing.bizActions)
3310
- ? existing.bizActions.filter((value) => typeof value === "string")
3311
- : [];
3312
- // Fail closed BEFORE any wire call when the caller names codes the handler
3313
- // does not carry — a typo'd ruleCode must not report a phantom success,
3314
- // and the existing codes are the fix's raw material.
3315
- const absent = codes.filter((code) => !priorActions.includes(code));
3316
- if (absent.length > 0) {
3317
- throw new ToolRefusalError({
3318
- status: "refused",
3319
- blocker: "workflow-unbind-rule-absent",
3320
- workflowCode: args.workflowCode,
3321
- absentRuleCodes: absent,
3322
- bizActions: priorActions,
3323
- ...(target.scope === "activity" ? { activityCode: target.activityCode, nodeEvent: target.key } : { handler: target.key }),
3324
- message: `该处理器当前没有绑定 ${absent.join("、")}——现有绑定:${priorActions.join("、") || "(无)"}。解绑只对已绑定的 code 生效;要换目标先看 workflow.get_draft 的 ruleBindings/nodeRuleBindings`,
3325
- });
3326
- }
3327
- const nextActions = priorActions.filter((code) => !codes.includes(code));
3328
- // 移空后的写回形状按平台 canonical 未绑态:handler 对象保留、bizActions 与
3329
- // bizActionType 置 null(WorkflowTemplateController 的模板示例即此形状;平台
3330
- // 判空走 CollectionUtils.isEmpty,null 与 [] 等价,null 是平台自己的存量拼写)。
3331
- const mergedHandler = nextActions.length > 0
3332
- ? { ...(typeof existing === "object" && existing ? existing : {}), bizActions: nextActions, bizActionType: "BIZ_RULE" }
3333
- : { ...(typeof existing === "object" && existing ? existing : {}), bizActions: null, bizActionType: null };
3334
- let nextTemplate;
3335
- if (target.scope === "workflow") {
3336
- nextTemplate = { ...draft, [target.field]: mergedHandler, workflowCode: args.workflowCode, schemaCode: args.schemaCode };
3337
- }
3338
- else {
3339
- // Keep the draft's activities container shape (array or index-keyed
3340
- // object) — only the selected row's handler field changes.
3341
- nextTemplate = mapTemplateActivity(draft, target.activityCode, (row) => ({ ...row, [target.field]: mergedHandler })).template;
3342
- nextTemplate = { ...nextTemplate, workflowCode: args.workflowCode, schemaCode: args.schemaCode };
3343
- }
3344
- validateWorkflowRender(nextTemplate, "workflow.unbindRule");
3381
+ // 读回+校验与 dry-run 共用 unbindRuleContext(同 refusal、同答案)。
3382
+ const { target, codes, shouldPublish, nextTemplate } = await unbindRuleContext(session, args);
3383
+ const handlerOf = (template) => bindTargetHandlerOf(template, target);
3345
3384
  const performed = await wireCall(session, {
3346
3385
  path: ENDPOINTS.workflowUpdate,
3347
3386
  method: "POST",
@@ -3409,6 +3448,29 @@ export function registerWorkflowLane(tools) {
3409
3448
  throw new ToolRefusalError({ status: "refused", blocker: "workflow-bindrule-codes-invalid", message: "ruleCodes 必须是非空、去重的规则 code 数组" });
3410
3449
  }
3411
3450
  },
3451
+ // dry-run 与真写同答案:读回+校验走 execute 同一个 unbindRuleContext——
3452
+ // 不存在流程 / 不存在活动 / absent code 在 dry-run 就拿到与真写完全相同的
3453
+ // refusal(打错 ruleCode 不再先亮 wouldChange:true);全过则回预览载荷。
3454
+ dryRunPayload: async (session, args) => {
3455
+ const ctx = await unbindRuleContext(session, args);
3456
+ const targetShape = ctx.target.scope === "workflow"
3457
+ ? { handler: ctx.target.key, handlerField: ctx.target.field }
3458
+ : { activityCode: ctx.target.activityCode, nodeEvent: ctx.target.key, nodeEventField: ctx.target.field };
3459
+ return {
3460
+ workflowCode: args.workflowCode,
3461
+ scope: ctx.target.scope,
3462
+ ...targetShape,
3463
+ removedRuleCodes: ctx.codes,
3464
+ currentBizActions: ctx.priorActions,
3465
+ remainingBizActions: ctx.nextActions,
3466
+ handlerWillBeCleared: ctx.nextActions.length === 0,
3467
+ publish: ctx.shouldPublish,
3468
+ ruleEnableUntouched: true,
3469
+ summary: writeSummary("workflow.unbindRule", args, undefined, "plan"),
3470
+ };
3471
+ },
3472
+ lintScope: "full",
3473
+ lintUnchecked: ["platform-side-validation", "post-write-readback"],
3412
3474
  rollback: workflowRollbackSpec("workflow.unbindRule"),
3413
3475
  });
3414
3476
  /**
package/dist/package.js CHANGED
@@ -19,6 +19,7 @@ export async function executePackage(ctx, plan, coverage, args, execute) {
19
19
  confirmProduction: args.confirmProduction,
20
20
  dryRun: args.dryRun,
21
21
  capability: args.capability,
22
+ ...(ctx.writeAudit?.reason !== undefined ? { reason: ctx.writeAudit.reason } : {}),
22
23
  coverage: claims,
23
24
  plan: () => plan,
24
25
  // A package dry-run is a TRUE preview: the environment is resolved and the
@@ -33,7 +34,7 @@ export async function executePackage(ctx, plan, coverage, args, execute) {
33
34
  });
34
35
  if (outcome.kind === "settled")
35
36
  return outcome.result;
36
- const { session, plan: boundPlan, productionConfirmed } = outcome.admission;
37
+ const { session, plan: boundPlan, productionConfirmed, reason } = outcome.admission;
37
38
  return ctx.lease.run(session.environmentName, `${plan.actions[0]?.tool ?? "package"}:${randomUUID().slice(0, 8)}`, async () => {
38
39
  const executed = await execute(session);
39
40
  if (isPackageStopOutcome(executed)) {
@@ -45,6 +46,7 @@ export async function executePackage(ctx, plan, coverage, args, execute) {
45
46
  failedStep: executed.failedStep,
46
47
  stop: executed.envelope,
47
48
  ...(productionConfirmed ? { productionConfirmed: true } : {}),
49
+ ...(reason !== undefined ? { reason } : {}),
48
50
  deliveryState: "STOPPED",
49
51
  recordedAt: new Date().toISOString(),
50
52
  };
@@ -63,11 +65,12 @@ export async function executePackage(ctx, plan, coverage, args, execute) {
63
65
  steps,
64
66
  readback,
65
67
  ...(productionConfirmed ? { productionConfirmed: true } : {}),
68
+ ...(reason !== undefined ? { reason } : {}),
66
69
  deliveryState: "DELIVERED",
67
70
  recordedAt: new Date().toISOString(),
68
71
  };
69
72
  writeArtifact(ctx, `package-${randomUUID().slice(0, 8)}.json`, artifact);
70
- return { status: "ok", deliveryState: "DELIVERED", steps, readback, ...(productionConfirmed ? { productionConfirmed: true } : {}), ...(summary !== undefined ? { summary } : {}), artifactFingerprint: sha256(artifact) };
73
+ return { status: "ok", deliveryState: "DELIVERED", steps, readback, ...(productionConfirmed ? { productionConfirmed: true } : {}), ...(reason !== undefined ? { reason } : {}), ...(summary !== undefined ? { summary } : {}), artifactFingerprint: sha256(artifact) };
71
74
  });
72
75
  }
73
76
  //# sourceMappingURL=package.js.map
@@ -517,11 +517,38 @@ export function nullProjectionHint(nullEntries, total) {
517
517
  * 这类只在 result 层有的键;`--jq modelsCount` 却去 artifact 副本里找,
518
518
  * 于是 pathMiss,且 `available` 列的是 artifact 的键——调用方看到"键明明打印过
519
519
  * 却说没有"。这里把事实补回去:该路径在 result 层存在时明确指路。
520
+ *
521
+ * retro issue 19 第三变体:result 层的同名键也可能是回执的**摘要投影**(如
522
+ * workflow.get_published 外置后的顶层 activities——形状与 artifact 正文完全
523
+ * 不同,元素常缺深层键),再无条件教「不带 --jq 直接读回执」会把人导向摘要面。
524
+ * 两头说清:正文里能解析同名键(pathMissCopyablePaths 已验证)就给可复制
525
+ * 命令;解析不了就说明形状差异并给结构性探索建议;只有正文**完全无同名键**
526
+ * (modelsCount 这类纯回执派生键)才保留「直接读回执」的旧指路。
520
527
  */
521
- function resultLayerNote(result, path) {
528
+ function resultLayerNote(result, path, artifactSource, at) {
522
529
  const head = path.replace(/^\$\.?/, "").split(/[.\[]/)[0];
523
530
  if (head === "" || !(head in result))
524
531
  return undefined;
532
+ // 与 pathMissCopyableHint 同一解析器:只在候选路径**能解析**时才输出,
533
+ // 绝不给出解析不了的假路径(issue 19 的语义门)。
534
+ const copyable = pathMissCopyablePaths(artifactSource, path, at, 1);
535
+ if (copyable.length > 0) {
536
+ return {
537
+ existsOnResult: head,
538
+ summaryProjection: true,
539
+ resultLayerHint: `result 顶层的「${head}」是摘要投影(形状与 artifact 正文不同,深层键常缺席),不要按它取值;正文里的真实路径:--jq '${copyable[0].replace(/'/g, "'\\''")}'`,
540
+ };
541
+ }
542
+ // 正文里有同名键但完整路径解析不了(如该流程无绑定、元素缺深层键):
543
+ // 说清差异 + 指向正文实际结构,不编造路径。
544
+ const bodyKey = collectKeyPaths(artifactSource, head).find((candidate) => candidate !== head);
545
+ if (bodyKey !== undefined) {
546
+ return {
547
+ existsOnResult: head,
548
+ summaryProjection: true,
549
+ resultLayerHint: `result 顶层的「${head}」是摘要投影(形状与 artifact 正文不同,深层键常缺席);正文同名键在 ${bodyKey},但该路径在正文里也不可解析(深层键缺席)。先用 artifact get --shape ${bodyKey} 看正文实际结构再定位`,
550
+ };
551
+ }
525
552
  return {
526
553
  existsOnResult: head,
527
554
  resultLayerHint: `「${head}」在 result 顶层(只是不在 artifact 副本里)。取它请不带 --jq 直接读回执,或改取 artifact 内的键(见 available)`,
@@ -759,7 +786,7 @@ export function projectResultExtract(result, paths, keysOnly) {
759
786
  ...(fan.availableTruncated !== undefined ? { availableTruncated: fan.availableTruncated } : {}),
760
787
  missedEntries: fan.missedEntries,
761
788
  ...(didYouMean !== undefined ? { didYouMean } : {}),
762
- ...(readFromArtifact ? resultLayerNote(result, path) ?? {} : {}),
789
+ ...(readFromArtifact ? resultLayerNote(result, path, projectionSource, fan.at) ?? {} : {}),
763
790
  hint: missHintFor(path, fan.at, fan.available, fan.availableAll),
764
791
  };
765
792
  }
@@ -796,7 +823,7 @@ export function projectResultExtract(result, paths, keysOnly) {
796
823
  available: single.available,
797
824
  ...(single.availableTruncated !== undefined ? { availableTruncated: single.availableTruncated } : {}),
798
825
  ...(didYouMean !== undefined ? { didYouMean } : {}),
799
- ...(readFromArtifact ? resultLayerNote(result, path) ?? {} : {}),
826
+ ...(readFromArtifact ? resultLayerNote(result, path, projectionSource, single.at) ?? {} : {}),
800
827
  hint: missHintFor(path, single.at, single.available, single.availableAll),
801
828
  };
802
829
  }
@@ -135,6 +135,13 @@ const READ_SHAPES = {
135
135
  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
136
  notes: ["与 workflow.get_published 同形(少了 published 键);节点绑定看 activities[].bizActions、系统活动顶层看 systemBizActions;templateType=DRAFT;深层字段投影写到叶子,完整模板在 data/detailArtifactId"],
137
137
  },
138
+ // R88 #1:双面排查面。returnsFace 只显 notes 首条——教学并进首条。
139
+ "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"],
141
+ notes: [
142
+ "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
+ ],
144
+ },
138
145
  "rule.list": {
139
146
  keys: ["rules:array<{code,name,enabled,status,ruleVersion,defaultRule,preset,mappings?,mappingsUnavailable?}>", "rulesCount", "modelPresent", "source", "executableHint", "mappingsWireNote?", "schemaCodes?/modelsCount?/models?:array<每模型同单模型回执>/partial?/failed?:array<{schemaCode,code,message}>/absentModels?"],
140
147
  notes: [