@stalfh233/omc-cli 0.8.14 → 0.8.15

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/write.js CHANGED
@@ -19,8 +19,8 @@ import { isUncertainWireError, sha256, wireErrorKind, writeArtifact } from "./su
19
19
  import { appendJournalEntry } from "./journal.js";
20
20
  import { journalAudit } from "./write-audit.js";
21
21
  import { capabilityArg, confirmProductionArg, environmentArg, WRITE_PROTOCOL } from "./args.js";
22
- import { plannableArgsRaw } from "./plan.js";
23
- import { defineTool, ToolRefusalError } from "./tool-types.js";
22
+ import { plannableArgs, plannableArgsRaw } from "./plan.js";
23
+ import { defineTool, isRequiredAlternativePlaceholder, ToolRefusalError } from "./tool-types.js";
24
24
  import { assertFieldFamilyAllowed } from "./field-families.js";
25
25
  import { validateBusinessCode, validateFieldEntryCodes } from "./code-rules.js";
26
26
  import { hardLayoutViolations, validateFormLayout } from "./form-layout.js";
@@ -31,6 +31,33 @@ import { WireError, optionPublishMessages } from "./wire.js";
31
31
  * The shared governed write pipeline and the low-level write registration
32
32
  * factory every lane adapter uses.
33
33
  */
34
+ /**
35
+ * The required-alternative placeholder is a validation-time internal value, not
36
+ * a parameter fact. `admitGovernedWrite` builds the plan from the RAW args before
37
+ * `writeLint` runs; the lint may then resolve a placeholder into a real value
38
+ * (workflow.delete's schemaCode reverse lookup). The dry-run receipt must preview
39
+ * the RESOLVED action args — otherwise it shows `__omc-required-alternative__`
40
+ * as if it were a real schemaCode. Real writes / rollback / journal already read
41
+ * the resolved args, so they are untouched.
42
+ */
43
+ function containsRequiredPlaceholder(value) {
44
+ if (isRequiredAlternativePlaceholder(value))
45
+ return true;
46
+ if (Array.isArray(value))
47
+ return value.some(containsRequiredPlaceholder);
48
+ if (value !== null && typeof value === "object")
49
+ return Object.values(value).some(containsRequiredPlaceholder);
50
+ return false;
51
+ }
52
+ function planWithResolvedArgs(plan, toolName, args) {
53
+ const unresolved = plan.actions.some((action) => action.tool === toolName && containsRequiredPlaceholder(action.args));
54
+ if (!unresolved)
55
+ return plan;
56
+ return {
57
+ ...plan,
58
+ actions: plan.actions.map((action) => (action.tool === toolName ? { ...action, args: plannableArgs(toolName, args) } : action)),
59
+ };
60
+ }
34
61
  /**
35
62
  * Shared governed write pipeline: coverage gate → environment write permission
36
63
  * → session → version evidence (advisory: recorded as `versionEvidence:"absent"`,
@@ -69,7 +96,7 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
69
96
  ? (plan, session) => dryRunPayload(session, args).then((payload) => ({
70
97
  status: "dry-run",
71
98
  wouldChange: true,
72
- plan,
99
+ plan: planWithResolvedArgs(plan, tool.name, args),
73
100
  idempotency: idempotencyDeclaration(tool.name, "none"),
74
101
  lintScope: lintDeclaration.lintScope,
75
102
  ...(lintDeclaration.lintUnchecked.length > 0 ? { unchecked: [...lintDeclaration.lintUnchecked] } : {}),
@@ -325,12 +352,29 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
325
352
  const artifactRef = writeArtifact(ctx, `${tool.name}-${randomUUID().slice(0, 8)}.json`, artifact);
326
353
  return { status: executed.status, steps: executed.steps, failedStep: executed.failedStep, ...executed.envelope, ...(args.requestId ? { requestId: args.requestId } : {}), artifactFingerprint: artifactRef.detailSha256 };
327
354
  }
328
- const { performed, readback, steps, halfSuccess, irreversible, rollbackReceipt, runtimeVerification, ruleStatus, serviceStatus } = executed;
355
+ const { performed, readback, steps, halfSuccess, irreversible, rollbackReceipt, runtimeVerification, ruleStatus, serviceStatus, status: producedStatus, blocker: producedBlocker, message: producedMessage, nextCommand: producedNextCommand, nextAction: producedNextAction, retryable: producedRetryable } = executed;
329
356
  // Readback gate (live 2026-10-17): a tool that reports `readback.present:false`
330
357
  // has NOT proven its own write — the platform accepted the request but the
331
358
  // object is absent from the authoritative face. "Called without error" must
332
359
  // never be stamped DELIVERED; downgrade to WRITE_UNVERIFIED and surface why.
333
- const { deliveryState, readbackWarning } = deliveryStateFor(readback);
360
+ const readbackGate = deliveryStateFor(readback);
361
+ // A producer-declared `uncertain` can never be DELIVERED either: it means the
362
+ // tool could not establish that the target belonged to the requested model
363
+ // (e.g. data.delete with a wrong schemaCode). Keep the gate's text when it
364
+ // already says something, otherwise use the producer's own diagnosis.
365
+ const writeStatus = producedStatus === "uncertain" ? "uncertain" : "ok";
366
+ const deliveryState = writeStatus === "uncertain" ? "WRITE_UNVERIFIED" : readbackGate.deliveryState;
367
+ // P1 复核:执行面的显式 uncertain 不能继承 `deliveryStateFor` 的 async 级联
368
+ // 文案——批量混合删除的 readback.absent=false 会被说成「删除级联中,稍后重跑」,
369
+ // 而真实结论是 delete-target-not-in-schema。生产者 blocker 优先。
370
+ const producedWarning = producedStatus === "uncertain"
371
+ ? (producedBlocker !== undefined
372
+ ? `本次调用未建立成功结论(${producedBlocker}):按 blocker/message/nextCommand 核对,勿当作已清理`
373
+ : producedMessage)
374
+ : undefined;
375
+ const readbackWarning = writeStatus === "uncertain"
376
+ ? (producedWarning ?? "本次调用不代表成功(WRITE_UNVERIFIED):目标是否属于该模型/是否已删除未建立;按 message/nextCommand 先核对,勿宣称已清理")
377
+ : readbackGate.readbackWarning;
334
378
  // Every production write echoes the explicit acknowledgement into the audit
335
379
  // trail, so the record can always answer "was this a confirmed production
336
380
  // write?".
@@ -368,7 +412,7 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
368
412
  // timeline (reverting a no-op delete would try to "restore" something that
369
413
  // never existed in this session).
370
414
  const skipped = typeof performed.skipped === "string" ? performed.skipped : undefined;
371
- const isNoopWrite = performed.noop === true || skipped === "already-absent" || skipped === "stale-record-cache";
415
+ const isNoopWrite = performed.noop === true || skipped === "already-absent" || skipped === "stale-record-cache" || skipped === "target-not-in-schema";
372
416
  let rollbackRef;
373
417
  if (tool.rollback && !isNoopWrite) {
374
418
  const entry = appendJournalEntry(ctx.artifactsDir, {
@@ -390,8 +434,13 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
390
434
  rollbackRef = { seq: entry.seq, hint: `omc rollback plan ${entry.seq}(--env ${entry.environment})` };
391
435
  }
392
436
  return {
393
- status: "ok",
437
+ status: writeStatus,
394
438
  deliveryState,
439
+ ...(writeStatus === "uncertain" && producedBlocker !== undefined ? { blocker: producedBlocker } : {}),
440
+ ...(writeStatus === "uncertain" && producedMessage !== undefined ? { message: producedMessage } : {}),
441
+ ...(writeStatus === "uncertain" && producedNextCommand !== undefined ? { nextCommand: producedNextCommand } : {}),
442
+ ...(writeStatus === "uncertain" && producedNextAction !== undefined ? { nextAction: producedNextAction } : {}),
443
+ ...(writeStatus === "uncertain" && producedRetryable !== undefined ? { retryable: producedRetryable } : {}),
395
444
  ...((typeof performed.applicationCode === "string" ? { applicationCode: performed.applicationCode } : typeof readback.applicationCode === "string" ? { applicationCode: readback.applicationCode } : {})),
396
445
  ...(readOnlyEscapeNote !== undefined ? { readOnlyEscape: readOnlyEscapeNote } : {}),
397
446
  performed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.8.14",
3
+ "version": "0.8.15",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "commander": "14.0.3",
61
- "omc-core": "0.8.14",
61
+ "omc-core": "0.8.15",
62
62
  "proper-lockfile": "4.1.2",
63
63
  "write-file-atomic": "6.0.0",
64
64
  "zod": "^3.23.8",
@@ -76,6 +76,6 @@
76
76
  "directory": "packages/omc-cli"
77
77
  },
78
78
  "optionalDependencies": {
79
- "@stalfh233/omc-fake-platform": "0.8.14"
79
+ "@stalfh233/omc-fake-platform": "0.8.15"
80
80
  }
81
81
  }
@@ -87,7 +87,7 @@ only the section for the capability you need —
87
87
  - **单据号/自动编号(原生,勿二开)**:自建单据号字段是 `field.create` 的 `SHORT_TEXT + options.formPropertyType:100 + options.seqNoSetting` 分段构建器(CONSTANT/DELIMITER/DATE/PROPERTY/SEQNO/UID 段);DATAITEM 不是段类型,而是设计师 UI 的 resetDate 显示值。SEQNO 段 `resetDate:DAY/MONTH/YEAR` 原生按期重置——`describe field.create --example field-serial-number`。**不要落 SequenceService SPI 二开**(真机 r50 + 8.6.26 反编译证据,2026-11-10);编号生成时机=submit(`data.save` 不生成)。系统 `sequenceNo` 控件另为 objectId 双轨,勿混淆。
88
88
 
89
89
  - **能做哪些事**:字段族全链 create→publish→表单绑定;**CHILD_TABLE 子表**(子列是 schemaCode=父字段 code 上的普通字段);**计算字段**(默认用普通字段 + 「计算规则」,见下)。
90
- - **工具**:`field.get`(单字段读 = `field.list` + `code` 选择器)、`field.list`、`field.create`、`field.update`、`field.publish`、`field.delete`
90
+ - **工具**:`field.get`(单字段/多字段读 = `field.list` + `code` 或 `fields[]` 选择器)、`field.list`、`field.create`、`field.update`、`field.publish`、`field.delete`
91
91
  - **recipe**:
92
92
  - `omc describe field.create --example numeric-two-decimals`(数值 + scale)
93
93
  - `omc describe field.create --example dictionary-backed-single-select`