@stalfh233/omc-cli 0.8.32 → 0.8.33
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/arg-vocabulary.js +223 -0
- package/dist/artifact-cmd.js +443 -0
- package/dist/batch-call.js +56 -3
- package/dist/call-command.js +70 -0
- package/dist/call-execute.js +228 -0
- package/dist/call-input.js +557 -0
- package/dist/call-output.js +240 -0
- package/dist/cli.js +13 -1359
- package/dist/command-transport.js +4 -1
- package/dist/form-support.js +14 -3
- package/dist/intent/plan-apply.js +14 -24
- package/dist/lanes/datarule.js +21 -0
- package/dist/lanes/field.js +31 -0
- package/dist/lanes/list-view-shapes.js +8 -1
- package/dist/lanes/list-view.js +64 -2
- package/dist/lanes/runtime-data/aggregate-support.js +209 -0
- package/dist/lanes/runtime-data/aggregate.js +679 -0
- package/dist/lanes/runtime-data/field-options.js +52 -0
- package/dist/lanes/runtime-data/lane.js +4 -0
- package/dist/lanes/runtime-data/record-delete.js +419 -0
- package/dist/lanes/runtime-data/record-read.js +984 -0
- package/dist/lanes/runtime-data/record-write.js +562 -0
- package/dist/lanes/runtime-data/registration.js +22 -0
- package/dist/lanes/runtime-data/shapes.js +594 -0
- package/dist/lanes/runtime-data/submission.js +1293 -0
- package/dist/lanes/runtime-data/write-support.js +875 -0
- package/dist/lanes/runtime-data.js +10 -5590
- package/dist/lanes/workflow/approval-ops.js +983 -0
- package/dist/lanes/workflow/instance-read.js +284 -0
- package/dist/lanes/workflow/lifecycle-write.js +1499 -0
- package/dist/lanes/workflow/permissions.js +571 -0
- package/dist/lanes/workflow/recovery.js +361 -0
- package/dist/lanes/workflow/registration.js +14 -0
- package/dist/lanes/workflow/shapes.js +811 -0
- package/dist/lanes/workflow/template-fetch.js +197 -0
- package/dist/lanes/workflow/template-merge.js +1351 -0
- package/dist/lanes/workflow/template-read.js +327 -0
- package/dist/lanes/workflow.js +11 -6312
- package/dist/read-projection.js +442 -0
- package/dist/read.js +40 -335
- package/dist/rollback.js +17 -23
- package/dist/runtime-support.js +1 -1
- package/dist/verification.js +39 -0
- package/dist/write-coordinator.js +152 -0
- package/dist/write-outcome.js +295 -0
- package/dist/write.js +34 -115
- package/package.json +3 -3
- package/skills/omc-refusals.md +1 -1
- package/skills/omc-start-here.md +2 -2
package/dist/read.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertWithinCoverage } from "./coverage.js";
|
|
2
|
-
import { wireErrorKind, isUncertainWireError,
|
|
2
|
+
import { wireErrorKind, isUncertainWireError, refusalFromCoverage, sha256, writeArtifact } from "./support.js";
|
|
3
|
+
import { READ_FULL_INLINE_CEILING_BYTES, omittedScalarKeys, passthroughScalars, projectReadResult, projectReadSemantics, } from "./read-projection.js";
|
|
3
4
|
import { plannableArgsRaw } from "./plan.js";
|
|
4
5
|
import { WireError } from "./wire.js";
|
|
5
6
|
import { describeWireFailure, isRetryableTransportKind } from "./wire-failure.js";
|
|
@@ -76,22 +77,17 @@ function transportDiagnostics(toolName, error, environment, retried, facts = des
|
|
|
76
77
|
* 40): 8 `workflow.get_* full:true` calls were 147 KB = 24% of the task, and the
|
|
77
78
|
* blob is re-read on every later turn.
|
|
78
79
|
*
|
|
79
|
-
* So the raw body is only inlined below
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* the
|
|
84
|
-
*
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*
|
|
89
|
-
* 字段 + 2 行子表(约 2–3KB)却被通用读面 diet 外置成 `data:null`,调用方必须
|
|
90
|
-
* 再跑一次 `omc artifact get`。单条记录不是「大列表」,与 items/logs/triggers
|
|
91
|
-
* 同列为小行集;只保留上限保护(与 `artifact get` 的内联上限同为 8192B),
|
|
92
|
-
* 超过仍外置。`data.list` 及其它工具的 2048 门不变。
|
|
80
|
+
* So the raw body is only inlined below the ceiling defined in
|
|
81
|
+
* read-projection.ts (`READ_FULL_INLINE_CEILING_BYTES`). Above it the caller
|
|
82
|
+
* gets the tool's compact semantic projection (which holds everything an edit
|
|
83
|
+
* needs) plus the artifact reference and a targeted-fetch hint. This does NOT
|
|
84
|
+
* change any platform write: write tools read the stored row server-side, never
|
|
85
|
+
* from the agent's readback (workflow.update/publish, field.update,
|
|
86
|
+
* form.publish, onlinejs.compose, service.update/method.update all self-read).
|
|
87
|
+
*
|
|
88
|
+
* 阈值、keyset 与外置判断的单一真相源现在是 `read-projection.ts` 的
|
|
89
|
+
* `ReadProjectionPolicy`;本文件只负责 artifact/缓存/信封的编排。
|
|
93
90
|
*/
|
|
94
|
-
const LOAD_RECORD_INLINE_CEILING_BYTES = FULL_INLINE_CEILING_BYTES;
|
|
95
91
|
/**
|
|
96
92
|
* Run composed sibling reads without the `unchanged` short-circuit, so a
|
|
97
93
|
* composite tool (model.inspect) receives their real payloads even after an
|
|
@@ -152,38 +148,29 @@ export async function governedRead(ctx, tool, args, execute, options = {}) {
|
|
|
152
148
|
if (ctx.readbackCacheBypass === 0 && cached && cached.environmentFingerprint === environmentFingerprint && cached.targetFingerprint === targetFingerprint && options.full !== true)
|
|
153
149
|
return { status: "ok", unchanged: true, detailFile: cached.detailFile, detailSha256: cached.detailSha256, ...(cached.shapePlaceholders ?? {}), environmentFingerprint };
|
|
154
150
|
const detail = { status: "ok", ...result, environmentFingerprint };
|
|
155
|
-
// 2026-11-01 预算批 v2(r38 usage 实证):1-4KB 中结果 59 次/135KB≈37% 全内联,
|
|
156
|
-
// model.inspect 17 次全部卡在旧门下。降到 2048;compact 对配置清单保形为码表
|
|
157
|
-
// (CODE_LIST_KEYS),完整正文仍在 detailArtifactId。
|
|
158
|
-
// r44fb: keep small row sets in the first envelope even when each row has
|
|
159
|
-
// useful detail (data.list items or rulelog nodes).
|
|
160
|
-
const smallRowSet = (Array.isArray(result.items) && result.items.length <= 10)
|
|
161
|
-
|| (Array.isArray(result.logs) && result.logs.length <= 10)
|
|
162
|
-
// 2026-11-22(0.6.93 真机,kind:"trigger"):触发器清单就是答案本体——
|
|
163
|
-
// 6 条就超 2048B 被折叠到 artifact,agent 还得再取一次。与 items/logs 同口径。
|
|
164
|
-
// 2026-11-23(0.6.97):数据规则纳入后单模型可达 30+ 行(1 条计算/校验规则
|
|
165
|
-
// 各一行)——30→60,仍是有界的小行集(长度规则已聚合,不会无限长)。
|
|
166
|
-
|| (Array.isArray(result.triggers) && result.triggers.length <= 60)
|
|
167
|
-
// F3(w71):单条记录(data.load)在 8192B 内联上限内不外置;缺席
|
|
168
|
-
// (exists:false)没有记录可外置,保持既有形状。
|
|
169
|
-
|| (tool.name === "data.load" && result.exists !== false && jsonBytes(result) <= LOAD_RECORD_INLINE_CEILING_BYTES);
|
|
170
|
-
const large = !smallRowSet && jsonBytes(result) > 2048;
|
|
171
151
|
const fileName = `${tool.name.replace(/[^a-zA-Z0-9._-]/g, "_")}-${sha256(target).slice(0, 16)}.json`;
|
|
172
152
|
const artifactRef = writeArtifact(ctx, fileName, detail);
|
|
173
153
|
const cacheEntry = { environmentFingerprint, targetFingerprint, detailFile: artifactRef.detailFile, detailSha256: artifactRef.detailSha256 };
|
|
154
|
+
// 投影 policy 的单一消费点:阈值/keyset/逐键例外全在 read-projection.ts。
|
|
155
|
+
// `projectReadResult` 只在外置档才付语义投影的成本(lane 的 compact 经
|
|
156
|
+
// `customProjection` 适配,不重写任何 lane)。
|
|
157
|
+
const plan = projectReadResult(result, {
|
|
158
|
+
toolName: tool.name,
|
|
159
|
+
full: options.full === true,
|
|
160
|
+
...(options.compact !== undefined ? { customProjection: (raw) => options.compact(raw, session) } : {}),
|
|
161
|
+
});
|
|
162
|
+
const rawBytes = plan.decision.bytes;
|
|
174
163
|
if (options.full === true) {
|
|
175
|
-
const rawBytes = jsonBytes(result);
|
|
176
164
|
// Small raw bodies keep the old inline behaviour; large ones are dieted
|
|
177
|
-
// (see
|
|
178
|
-
// the artifact, so no capability is lost — only the inline copy is skipped.
|
|
179
|
-
if (
|
|
165
|
+
// (see READ_FULL_INLINE_CEILING_BYTES). The raw body stays fully reachable
|
|
166
|
+
// via the artifact, so no capability is lost — only the inline copy is skipped.
|
|
167
|
+
if (plan.decision.inline) {
|
|
180
168
|
ctx.readbackCache.set(target, cacheEntry);
|
|
181
169
|
return { ...detail, detailFile: artifactRef.detailFile, detailSha256: artifactRef.detailSha256 };
|
|
182
170
|
}
|
|
183
|
-
const
|
|
171
|
+
const { payload: compact, placeholders } = requireProjection(plan);
|
|
184
172
|
// A1:外置与内联同形——被折叠的 payload 键补回空占位;缓存同样记占位,
|
|
185
173
|
// unchanged 二次读回时不丢形状(GitLab #15)。
|
|
186
|
-
const placeholders = externalizedShapePlaceholders(result, droppedShapeKeys(result, compact));
|
|
187
174
|
ctx.readbackCache.set(target, { ...cacheEntry, shapePlaceholders: placeholders });
|
|
188
175
|
return {
|
|
189
176
|
status: "ok",
|
|
@@ -193,18 +180,17 @@ export async function governedRead(ctx, tool, args, execute, options = {}) {
|
|
|
193
180
|
full: true,
|
|
194
181
|
fullOmitted: true,
|
|
195
182
|
fullBytes: rawBytes,
|
|
196
|
-
fullArtifactHint: `--full 的原生正文 ${rawBytes}B 超过内联上限 ${
|
|
183
|
+
fullArtifactHint: `--full 的原生正文 ${rawBytes}B 超过内联上限 ${READ_FULL_INLINE_CEILING_BYTES}B,已外置到 artifact;上面的语义投影含编辑所需字段,需要原生字段用 \`omc artifact get <detailArtifactId>\`(可 --jq <path> / --keys)定向取回,勿全量读入。`,
|
|
197
184
|
environmentFingerprint,
|
|
198
185
|
detailFile: artifactRef.detailFile,
|
|
199
186
|
detailSha256: artifactRef.detailSha256,
|
|
200
187
|
};
|
|
201
188
|
}
|
|
202
|
-
if (
|
|
189
|
+
if (plan.decision.inline) {
|
|
203
190
|
ctx.readbackCache.set(target, cacheEntry);
|
|
204
191
|
return { status: "ok", ...result, environmentFingerprint };
|
|
205
192
|
}
|
|
206
|
-
const
|
|
207
|
-
const placeholders = externalizedShapePlaceholders(result, droppedShapeKeys(result, compact));
|
|
193
|
+
const { payload: compact, placeholders } = requireProjection(plan);
|
|
208
194
|
ctx.readbackCache.set(target, { ...cacheEntry, shapePlaceholders: placeholders });
|
|
209
195
|
return { status: "ok", ...passthroughScalars(result, omittedScalarKeys(compact)), ...compact, ...placeholders, environmentFingerprint, detailFile: artifactRef.detailFile, detailSha256: artifactRef.detailSha256 };
|
|
210
196
|
}
|
|
@@ -235,301 +221,20 @@ export async function governedRead(ctx, tool, args, execute, options = {}) {
|
|
|
235
221
|
}
|
|
236
222
|
}
|
|
237
223
|
/**
|
|
238
|
-
* A1(GitLab #15,2026-11-04
|
|
239
|
-
*
|
|
240
|
-
* `
|
|
241
|
-
* 被折叠的键补回为空占位(原值是数组→[],否则 null)并标记 truncatedKeys;
|
|
242
|
-
* 真实数据在 detailFile 指向的 artifact 里,根键与内联一致(list=items、load=data)。
|
|
224
|
+
* A1(GitLab #15,2026-11-04):外置结果与内联同形 —— 保形占位、bulky keyset
|
|
225
|
+
* 与逐键判定现在都在 `read-projection.ts`(`ReadProjectionPolicy`)。这里保留
|
|
226
|
+
* `compactReadback` 的公开签名供 lane 复用(list-view 等),实现委托给默认 policy。
|
|
243
227
|
*/
|
|
244
|
-
function externalizedShapePlaceholders(result, dropped) {
|
|
245
|
-
// r26b:什么都没折叠时不要宣称 `truncated:true`——`model.list` 曾出现
|
|
246
|
-
// `truncated:true` + `truncatedKeys:[]`(models 已按 code|name 内联),
|
|
247
|
-
// 自相矛盾的标记会让调用方以为还得去 artifact 取。
|
|
248
|
-
if (dropped.length === 0)
|
|
249
|
-
return {};
|
|
250
|
-
// Keep the A1 empty/null placeholder shape, but explicitly distinguish it
|
|
251
|
-
// from a genuine empty payload. `omittedKeys` is the machine-readable face;
|
|
252
|
-
// `truncatedKeys` remains the legacy list of payload keys moved to artifact.
|
|
253
|
-
const placeholders = { truncatedKeys: [...dropped], omittedKeys: [...dropped], truncated: true };
|
|
254
|
-
for (const key of dropped)
|
|
255
|
-
placeholders[key] = Array.isArray(result[key]) ? [] : null;
|
|
256
|
-
// r57 真机(2026-11-12):`rules: []` 与 `truncated: true` 并置,第一眼像
|
|
257
|
-
// 「0 条但被截断」——实际是「11 条全在 artifact」。给一个机器可读标记,
|
|
258
|
-
// 调用方不必靠"空数组 + truncated"反推。
|
|
259
|
-
placeholders.omittedShape = "artifact";
|
|
260
|
-
placeholders.omittedNote = "被折叠的键保留空占位(保形:脚本可直接 .length/.map),真实内容是完整数据,用 detailArtifactId 取;空占位不代表 0 条。";
|
|
261
|
-
return placeholders;
|
|
262
|
-
}
|
|
263
|
-
function droppedShapeKeys(result, payload) {
|
|
264
|
-
return Object.keys(result).filter((key) => BULKY_READ_KEYS.has(key) && !(key in payload));
|
|
265
|
-
}
|
|
266
228
|
export function compactReadback(result) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
// customCount + rules 瘦身行(≤12,同顶层 rules 口径);三句提示已抬到
|
|
277
|
-
// crossModelNotes,不逐模型重复。
|
|
278
|
-
if (key === "models" && Array.isArray(value) && value.length > 0 &&
|
|
279
|
-
typeof value[0] === "object" && value[0] !== null &&
|
|
280
|
-
"modelPresent" in value[0]) {
|
|
281
|
-
compact[key] = value.map((model) => {
|
|
282
|
-
const rules = Array.isArray(model.rules) ? model.rules : [];
|
|
283
|
-
return {
|
|
284
|
-
schemaCode: model.schemaCode ?? null,
|
|
285
|
-
modelPresent: model.modelPresent ?? null,
|
|
286
|
-
rulesCount: typeof model.rulesCount === "number" ? model.rulesCount : rules.length,
|
|
287
|
-
...(model.customCount !== undefined ? { customCount: model.customCount } : {}),
|
|
288
|
-
rules: rules.slice(0, 12).map((rule) => ({
|
|
289
|
-
code: typeof rule.code === "string" ? rule.code : null,
|
|
290
|
-
name: typeof rule.name === "string" ? rule.name : null,
|
|
291
|
-
...(rule.enabled !== undefined ? { enabled: rule.enabled } : {}),
|
|
292
|
-
...(Array.isArray(rule.mappings) ? { mappings: rule.mappings } : {}),
|
|
293
|
-
...(rule.mappingsUnavailable === true ? { mappingsUnavailable: true } : {}),
|
|
294
|
-
})),
|
|
295
|
-
};
|
|
296
|
-
});
|
|
297
|
-
compact[`${key}Count`] = value.length;
|
|
298
|
-
}
|
|
299
|
-
else if (CODE_NAME_LIST_KEYS.has(key) && Array.isArray(value)) {
|
|
300
|
-
const pairs = value.map(codeNameOfEntry).filter((entry) => entry !== undefined);
|
|
301
|
-
// 40 对上限(~1-2KB):更大的清单回退 count+artifact,保冷启动可扫又不失控
|
|
302
|
-
if (pairs.length <= 40)
|
|
303
|
-
compact[key] = pairs;
|
|
304
|
-
else
|
|
305
|
-
compact[`${key}Count`] = value.length;
|
|
306
|
-
if (!compact[`${key}Count`])
|
|
307
|
-
compact[`${key}Count`] = value.length;
|
|
308
|
-
}
|
|
309
|
-
else if (key === "crossModelNotes" && value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
310
|
-
// r83:跨模型面抬上来的三句提示(逐模型相同,只存一份)——原样保留,
|
|
311
|
-
// 不被通用对象分支摘要成 {keys}(否则默认面丢教学)。
|
|
312
|
-
compact[key] = value;
|
|
313
|
-
}
|
|
314
|
-
else if (CODE_LIST_KEYS.has(key) && Array.isArray(value)) {
|
|
315
|
-
// 2026-11-01 预算批 v2:读门 4096→2048 后,中结果(r38 实测 model.inspect
|
|
316
|
-
// 17 次 51KB 全部卡旧门下全内联)走 compact——配置清单类数组保形为码表
|
|
317
|
-
// (不是只给 count),否则 agent 被迫二次 artifact get 反加回合。
|
|
318
|
-
compact[key] = value.map(codeOfEntry).filter((entry) => entry !== undefined);
|
|
319
|
-
compact[`${key}Count`] = value.length;
|
|
320
|
-
}
|
|
321
|
-
else if (ACTIVITY_LIST_KEYS.has(key) && Array.isArray(value)) {
|
|
322
|
-
compact[key] = value.map(activityOfEntry).filter((entry) => entry !== undefined);
|
|
323
|
-
compact[`${key}Count`] = value.length;
|
|
324
|
-
}
|
|
325
|
-
else if (key === "rules" && Array.isArray(value)) {
|
|
326
|
-
// r62b-F3(P1-10):rules 折叠成 `rules:[]`+artifact 曾逼探针二次取回——
|
|
327
|
-
// 9 条规则连名字都看不到。瘦身版 [{code,name,enabled,defaultRule}] ~40B/条,
|
|
328
|
-
// **≤12 条**内联(~500B,回答「配了哪些规则/几条自建几条预置」);更大的
|
|
329
|
-
// 清单保持外置语义(readback-diet 的 token 经济不变),正文仍在 artifact。
|
|
330
|
-
if (value.length <= 12) {
|
|
331
|
-
const slim = value
|
|
332
|
-
.map((rule) => ({
|
|
333
|
-
code: typeof rule.code === "string" ? rule.code : null,
|
|
334
|
-
name: typeof rule.name === "string" ? rule.name : null,
|
|
335
|
-
...(rule.enabled !== undefined ? { enabled: rule.enabled } : {}),
|
|
336
|
-
...(rule.defaultRule !== undefined ? { defaultRule: rule.defaultRule } : {}),
|
|
337
|
-
// r83:rule.list --withMappings 的映射摘要随行保留(否则 >2048B 的
|
|
338
|
-
// 常见 7 条预置规则会「开了 withMappings 却在默认面看不到映射」);
|
|
339
|
-
// 只有显式开启该参数的行才有这个键,其余工具的 rules 不受影响。
|
|
340
|
-
...(Array.isArray(rule.mappings) ? { mappings: rule.mappings } : {}),
|
|
341
|
-
...(rule.mappingsUnavailable === true ? { mappingsUnavailable: true } : {}),
|
|
342
|
-
}));
|
|
343
|
-
compact[key] = slim;
|
|
344
|
-
}
|
|
345
|
-
compact[`${key}Count`] = value.length;
|
|
346
|
-
}
|
|
347
|
-
else if (BULKY_READ_KEYS.has(key)) {
|
|
348
|
-
compact[`${key}Count`] = Array.isArray(value) ? value.length : value && typeof value === "object" ? Object.keys(value).length : 0;
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
// r28a 真机(2026-11-05):`summarizeValue` 对数组给 `{count}`、对对象给
|
|
352
|
-
// `{keys}`,两套占位形状本身没有「数据不在我这里」的语义——`count: 8`
|
|
353
|
-
// 读起来像"已经给你 8 条"。同一个逻辑清单(dictionary.names 回数组、
|
|
354
|
-
// dictionary.list 回分页对象)于是给出两种自相矛盾的占位。
|
|
355
|
-
// 这里统一补 `omitted:true`(真实数据在 detailArtifactId),不动
|
|
356
|
-
// summarizeValue 本身——它还服务于 dry-run 的 argsSummary,那里"摘要"
|
|
357
|
-
// 才是正确语义。
|
|
358
|
-
// r28a 的 omitted 补丁有副作用(本轮全量门抓到):`summarizeValue` 对**任何**
|
|
359
|
-
// 对象都给 `{keys}`,连只有 3 个键的小对象也不例外——`model.list` 的
|
|
360
|
-
// `applicationResolution: {code, source, applicationCount}` 由此变成
|
|
361
|
-
// `{keys, sha256, omitted}`,而它正是「零命中只代表这一个应用」的唯一证据。
|
|
362
|
-
// 规则:小对象(≤4 键且 ≤200B)原样内联——折叠它是纯损失,不是省字节。
|
|
363
|
-
// 2026-11-22(0.6.93 真机):教学/证据键被 compact 折叠等于把结论吞掉——
|
|
364
|
-
// `notScanned`(4 行字符串)变 {count:4,sha256,omitted}、`scanned`/`coverage`/
|
|
365
|
-
// `applicationResolution` 同样中招,读起来像"有数据",实际一个字都没有。
|
|
366
|
-
// 这些键按设计就是小体量(计数/几行字符串),按上限原样内联;超限才折叠。
|
|
367
|
-
if (ALWAYS_INLINE_KEYS.has(key) && jsonBytes(value) <= ALWAYS_INLINE_KEYS.get(key)) {
|
|
368
|
-
compact[key] = value;
|
|
369
|
-
continue;
|
|
370
|
-
}
|
|
371
|
-
const small = value !== null && typeof value === "object" && !Array.isArray(value)
|
|
372
|
-
&& Object.keys(value).length <= 4
|
|
373
|
-
&& Buffer.byteLength(JSON.stringify(value), "utf8") <= 200;
|
|
374
|
-
if (small) {
|
|
375
|
-
compact[key] = value;
|
|
376
|
-
continue;
|
|
377
|
-
}
|
|
378
|
-
// 2026-11-21(0.6.91 真机,05b childRowsHint):教学串不是数据。hint 类
|
|
379
|
-
// 字符串被 summarizeValue 折成 `{length,sha256,omitted}` 等于把教学本身
|
|
380
|
-
// 废掉——`data.load` 的内联子表 hint 209B 就这样变成了一个摘要(读起来
|
|
381
|
-
// 像"有 hint",实际一个字都读不到)。与上面 small-object 同一条规则:
|
|
382
|
-
// 折叠它是纯损失。上限 1200B 防异常长串,超过才摘要。
|
|
383
|
-
if (typeof value === "string" && /Hint$/.test(key) && Buffer.byteLength(value, "utf8") <= 1200) {
|
|
384
|
-
compact[key] = value;
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
const summarized = summarizeValue(value);
|
|
388
|
-
compact[key] = summarized !== null && typeof summarized === "object" && !Array.isArray(summarized)
|
|
389
|
-
? { ...summarized, omitted: true }
|
|
390
|
-
: summarized;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return compact;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* 2026-11-22(0.6.93 真机):compact 路径必须原样保留的**教学/证据**键及其上限
|
|
397
|
-
* (JSON 字节)。这些键不是数据正文,体量由设计保证;折叠它们只会把结论变成
|
|
398
|
-
* `{count,sha256,omitted}`(`notScanned`/`scanned`/`coverage` 真机实证)。
|
|
399
|
-
*/
|
|
400
|
-
const ALWAYS_INLINE_KEYS = new Map([
|
|
401
|
-
["notScanned", 2000],
|
|
402
|
-
["note", 1200],
|
|
403
|
-
["scanNote", 1200],
|
|
404
|
-
["doNot", 600],
|
|
405
|
-
["scanned", 600],
|
|
406
|
-
["coverage", 1200],
|
|
407
|
-
["applicationResolution", 600],
|
|
408
|
-
["summaryHint", 600],
|
|
409
|
-
]);
|
|
410
|
-
/** Config-inventory keys that compact to a code list (not a bare count). */
|
|
411
|
-
const CODE_LIST_KEYS = new Set(["fields", "columns", "conditions", "sorts", "datarules", "buttons", "views", "sheets"]);
|
|
412
|
-
/**
|
|
413
|
-
* 码不自解释的清单(2026-11-02 用户实测反馈):角色/模型/部门冷启动扫描
|
|
414
|
-
* 是刚需,但裸 code(SYS_1000000)不可读、全量 dump 又是 113×全字段的
|
|
415
|
-
* 上下文灾难——内联为 `code|name` 对,超大时仍回退 count+artifact。
|
|
416
|
-
*/
|
|
417
|
-
const CODE_NAME_LIST_KEYS = new Set(["roles", "groups", "models", "departments", "workflows", "services", "methods"]);
|
|
418
|
-
/** 节点类清单:参与者是扫描目标(r46 用户实测:逐模型拉全权限数组找审批人)——
|
|
419
|
-
* 内联 `code:name@participant`,权限明细仍在 artifact。 */
|
|
420
|
-
const ACTIVITY_LIST_KEYS = new Set(["activities"]);
|
|
421
|
-
function codeNameOfEntry(entry) {
|
|
422
|
-
const code = codeOfEntry(entry);
|
|
423
|
-
if (code === undefined)
|
|
424
|
-
return undefined;
|
|
425
|
-
const name = typeof entry.name === "string" && entry.name.length > 0 ? entry.name : undefined;
|
|
426
|
-
return name === undefined ? code : `${code}|${name}`;
|
|
427
|
-
}
|
|
428
|
-
function activityOfEntry(entry) {
|
|
429
|
-
const code = typeof entry.code === "string" && entry.code.length > 0 ? entry.code : typeof entry.activityCode === "string" ? entry.activityCode : undefined;
|
|
430
|
-
if (code === undefined)
|
|
431
|
-
return undefined;
|
|
432
|
-
const name = typeof entry.name === "string" && entry.name.length > 0 ? entry.name : "";
|
|
433
|
-
const participantRaw = entry.participant ?? entry.participants;
|
|
434
|
-
const participant = typeof participantRaw === "string" ? participantRaw : participantRaw && typeof participantRaw === "object" ? JSON.stringify(participantRaw) : "";
|
|
435
|
-
return `${code}${name ? `:${name}` : ""}${participant ? `@${participant.slice(0, 48)}` : ""}`;
|
|
436
|
-
}
|
|
437
|
-
function codeOfEntry(entry) {
|
|
438
|
-
for (const key of ["propertyCode", "code", "schemaCode", "ruleCode", "fieldCode"]) {
|
|
439
|
-
const value = entry[key];
|
|
440
|
-
if (typeof value === "string" && value.length > 0)
|
|
441
|
-
return value;
|
|
442
|
-
}
|
|
443
|
-
return undefined;
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Keys whose values are the bulk a compact projection replaces with a count.
|
|
447
|
-
* Everything else is a small facet identity/decision fields (workflowCode,
|
|
448
|
-
* exists, published, id, code, schemaCode, note, …).
|
|
449
|
-
*/
|
|
450
|
-
const BULKY_READ_KEYS = new Set(["data", "nodes", "routes", "items", "rules", "applications", "foldersAndModels", "models"]);
|
|
451
|
-
const CONTAINER_NAME_KEYS = [
|
|
452
|
-
"items",
|
|
453
|
-
"models",
|
|
454
|
-
"rules",
|
|
455
|
-
"logs",
|
|
456
|
-
"triggers",
|
|
457
|
-
"fields",
|
|
458
|
-
"records",
|
|
459
|
-
...[...BULKY_READ_KEYS, ...CODE_LIST_KEYS, ...CODE_NAME_LIST_KEYS, ...ACTIVITY_LIST_KEYS],
|
|
460
|
-
];
|
|
461
|
-
/**
|
|
462
|
-
* 回执派生/诊断用数组不是「结果容器」:`failed[]`(部分失败清单)、`truncatedKeys`
|
|
463
|
-
* (被折叠的键名)这类在部分失败时可能比数据本身还长,按长度挑会挑错。
|
|
464
|
-
*/
|
|
465
|
-
const NON_CONTAINER_KEYS = new Set(["failed", "failures", "truncatedKeys", "omittedKeys", "changedKeys", "unknownKeys"]);
|
|
466
|
-
export function containerKeyOf(result) {
|
|
467
|
-
if (result === null || typeof result !== "object" || Array.isArray(result))
|
|
468
|
-
return undefined;
|
|
469
|
-
const record = result;
|
|
470
|
-
const arrays = Object.entries(record).filter(([key, value]) => Array.isArray(value) && !NON_CONTAINER_KEYS.has(key));
|
|
471
|
-
const objectArrays = arrays.filter(([, value]) => value.length > 0 && value[0] !== null && typeof value[0] === "object" && !Array.isArray(value[0]));
|
|
472
|
-
if (objectArrays.length > 0) {
|
|
473
|
-
const [key] = objectArrays.reduce((best, entry) => (entry[1].length > best[1].length ? entry : best));
|
|
474
|
-
return { key };
|
|
475
|
-
}
|
|
476
|
-
for (const name of CONTAINER_NAME_KEYS) {
|
|
477
|
-
if (arrays.some(([key]) => key === name))
|
|
478
|
-
return { key: name };
|
|
479
|
-
}
|
|
480
|
-
// 分页壳:`{records:{totalElements,content:[…]}}` —— 容器在下一层,键名仍要给出。
|
|
481
|
-
for (const [key, value] of Object.entries(record)) {
|
|
482
|
-
if (value !== null && typeof value === "object" && !Array.isArray(value) && Array.isArray(value.content))
|
|
483
|
-
return { key, path: `${key}.content` };
|
|
484
|
-
}
|
|
485
|
-
return undefined;
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Carry the handler's small top-level facets through a compact projection.
|
|
489
|
-
*
|
|
490
|
-
* A lane's compact function reduces the result to its own summary shape and can
|
|
491
|
-
* drop scalar identity/decision keys the handler set at the top level — e.g.
|
|
492
|
-
* `workflow.get_draft` returns `{ workflowCode, exists, published, data }`, but
|
|
493
|
-
* `workflowCompactProjection` emitted only `workflowSummary`, so a caller reading
|
|
494
|
-
* `result.workflowCode` got `undefined` (round 10: live demo). Pass the scalar
|
|
495
|
-
* (non-bulky) top-level keys through; the compact's own keys still win.
|
|
496
|
-
*/
|
|
497
|
-
function passthroughScalars(result, omit = []) {
|
|
498
|
-
const carried = {};
|
|
499
|
-
for (const [key, value] of Object.entries(result)) {
|
|
500
|
-
if (key === "status" || BULKY_READ_KEYS.has(key) || omit.includes(key))
|
|
501
|
-
continue;
|
|
502
|
-
const type = typeof value;
|
|
503
|
-
if (value === null || type === "string" || type === "number" || type === "boolean")
|
|
504
|
-
carried[key] = value;
|
|
505
|
-
}
|
|
506
|
-
return carried;
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* T1(GitLab #17):某个工具的自定义 compact 用 `<key>Omitted` 显式声明"这段正文
|
|
510
|
-
* 已外置"(form.get 的六份布局 JSON 是大**字符串**,不是 BULKY_READ_KEYS 里的
|
|
511
|
-
* 数组/对象)。passthroughScalars 会把所有字符串原样带回来,正好把外置又抵消掉
|
|
512
|
-
* (42KB 读回里 41KB 是刚声明省略的布局)。这里把省略声明翻译成跳过名单。
|
|
513
|
-
*
|
|
514
|
-
* 白名单化(审查 2026-11-04):只认 form 的六个布局面。否则任何 compact 恰好
|
|
515
|
-
* 产出的 `<key>Omitted:true`(如 `fullOmitted` → 派生 omit=`full`)都会误删同名
|
|
516
|
-
* 标量,靠后续展开掩盖太脆。
|
|
517
|
-
*/
|
|
518
|
-
const EXTERNALIZED_SCALAR_KEYS = new Set([
|
|
519
|
-
"draftViewJson",
|
|
520
|
-
"draftAttributesJson",
|
|
521
|
-
"draftHtmlJson",
|
|
522
|
-
"draftActionsJson",
|
|
523
|
-
"publishedViewJson",
|
|
524
|
-
"publishedAttributesJson",
|
|
525
|
-
"publishedHtmlJson",
|
|
526
|
-
"publishedActionsJson",
|
|
527
|
-
]);
|
|
528
|
-
function omittedScalarKeys(compact) {
|
|
529
|
-
return Object.keys(compact)
|
|
530
|
-
.filter((key) => key.endsWith("Omitted") && compact[key] === true)
|
|
531
|
-
.map((key) => key.slice(0, -"Omitted".length))
|
|
532
|
-
.filter((key) => EXTERNALIZED_SCALAR_KEYS.has(key));
|
|
229
|
+
return projectReadSemantics(result);
|
|
230
|
+
}
|
|
231
|
+
/** C7:结果容器键自描述;判定规则与容器名顺序由 `read-projection.ts` 的 policy 持有。 */
|
|
232
|
+
export { containerKeyOf } from "./read-projection.js";
|
|
233
|
+
/** 外置档必然带语义投影;落成独立函数只为把这条不变量写在一处。 */
|
|
234
|
+
function requireProjection(plan) {
|
|
235
|
+
if (plan.projection === undefined)
|
|
236
|
+
throw new Error("read projection plan is inconsistent: externalized without a projection");
|
|
237
|
+
return plan.projection;
|
|
533
238
|
}
|
|
534
239
|
function safeFingerprint(session) {
|
|
535
240
|
try {
|
package/dist/rollback.js
CHANGED
|
@@ -8,7 +8,7 @@ import { readJournal, resolveJournalEntry, laterWritesOnTarget } from "./journal
|
|
|
8
8
|
import { canonicalForVerify, deepDiff, pruneNullish } from "./rollback-spec.js";
|
|
9
9
|
import { sha256 } from "./support.js";
|
|
10
10
|
import { emitTransportResult, emitInvalid } from "./command-transport.js";
|
|
11
|
-
import {
|
|
11
|
+
import { writeCoordinator, WriteLockConflictError } from "./write-coordinator.js";
|
|
12
12
|
import { resolveSinceRef } from "./duration.js";
|
|
13
13
|
import { normalizeWriteReason } from "./write-audit.js";
|
|
14
14
|
import { appendBatchAuditLine, executeGovernedBatch } from "./batch-executor.js";
|
|
@@ -245,32 +245,17 @@ export async function applyRollback(ref, options, context) {
|
|
|
245
245
|
// shapes still become governed calls here, without changing the evidence
|
|
246
246
|
// or lock protocol.
|
|
247
247
|
const waitMs = options.waitMs ?? 0;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
lock = await acquireWriteLock(entry.environment);
|
|
252
|
-
if (lock.held)
|
|
253
|
-
break;
|
|
254
|
-
if (Date.now() >= deadline) {
|
|
255
|
-
return {
|
|
256
|
-
status: "refused",
|
|
257
|
-
blocker: "write-lock-held",
|
|
258
|
-
rollbackOf: { seq: entry.seq, tool: entry.tool },
|
|
259
|
-
waitMs,
|
|
260
|
-
lockOwner: lock.owner ?? null,
|
|
261
|
-
message: `回滚写锁被占用;已等待 ${waitMs}ms。可用 --wait <ms> 有界排队后重试`,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
await new Promise((resolve) => setTimeout(resolve, Math.min(200, Math.max(0, deadline - Date.now()))));
|
|
265
|
-
}
|
|
248
|
+
// Narrowed once, outside the leased operation: TS does not carry the earlier
|
|
249
|
+
// `kind !== "calls"` guard into a closure.
|
|
250
|
+
const inverseCalls = plan.inverse.calls;
|
|
266
251
|
let progressFile;
|
|
267
252
|
let batchSteps = [];
|
|
268
|
-
|
|
253
|
+
const executeRestore = async () => {
|
|
269
254
|
// B1:执行段(串行/首败即停/超时冻结/progressFile)由共享 governed batch
|
|
270
255
|
// executor 承担;本面只负责「怎么重放一次恢复调用」(真实 tool handler +
|
|
271
256
|
// 每次 requestId)和把结果投影回旧回执字段(results/step/status 逐字不变)。
|
|
272
257
|
const executed = await executeGovernedBatch({
|
|
273
|
-
changes:
|
|
258
|
+
changes: inverseCalls.map((call) => ({ tool: call.tool, args: call.args })),
|
|
274
259
|
mode: "rollback",
|
|
275
260
|
progress: { ctx, summary: restoreReason },
|
|
276
261
|
runTool: async (call, index) => {
|
|
@@ -331,10 +316,19 @@ export async function applyRollback(ref, options, context) {
|
|
|
331
316
|
});
|
|
332
317
|
progressFile = executed.progressFile;
|
|
333
318
|
batchSteps = executed.steps;
|
|
319
|
+
return undefined;
|
|
320
|
+
};
|
|
321
|
+
let stopped;
|
|
322
|
+
try {
|
|
323
|
+
stopped = await writeCoordinator.run({ environment: entry.environment, tool: "rollback", waitMs, mode: "rollback", rollbackOf: { seq: entry.seq, tool: entry.tool } }, executeRestore);
|
|
334
324
|
}
|
|
335
|
-
|
|
336
|
-
|
|
325
|
+
catch (error) {
|
|
326
|
+
if (!(error instanceof WriteLockConflictError))
|
|
327
|
+
throw error;
|
|
328
|
+
return error.conflict.receipt;
|
|
337
329
|
}
|
|
330
|
+
if (stopped !== undefined)
|
|
331
|
+
return stopped;
|
|
338
332
|
// Authoritative verify: re-read the target and compare against the
|
|
339
333
|
// canonicalized before. "restored" tolerates the write pipeline
|
|
340
334
|
// EXPLICITIFYING platform defaults the bare auto-draft left absent
|
package/dist/runtime-support.js
CHANGED
|
@@ -318,7 +318,7 @@ export function buildSubmitWorkitemNotMineRefusal(input) {
|
|
|
318
318
|
`待办持有者:${awaiting.map((row) => `${row.activityName ?? row.activityCode ?? "?"} → ${row.participants.join("/")}`).join(";")}。` +
|
|
319
319
|
`**这是 OMC 的能力边界**:平台按登录态鉴权,而 OMC 一次只持有一个会话(一份 token 缓存),` +
|
|
320
320
|
`因此「非发起人身份的审批」无法在 CLI 内推进。可选做法:① 由该参与人自己在门户审批;` +
|
|
321
|
-
`② 用该参与人的账号另建一个环境(omc
|
|
321
|
+
`② 用该参与人的账号另建一个环境(omc setup 建一个该账号的环境,凭据落在本机)再执行同一条 data.submit;` +
|
|
322
322
|
`③ 若只是为了验证流程能走通,把该节点参与人临时改为发起人(org.role.addUsers / workflow.update),验证后改回——` +
|
|
323
323
|
`**仅限本地沙盒且必须当场还原;生产/客户环境禁用**(漏还原=把假权限交付给客户)。` +
|
|
324
324
|
`或改用 workflow.transfer 把待办转给当前登录人再 data.submit(会写 ADJUST_PARTICIPANT 审计记录,且转过的实例勿再用于权限验证)。` +
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置已等价读回,但运行面**不可用/不覆盖**这条配置(例如 REST 不应用视图
|
|
3
|
+
* 固定条件、REST 不跑 options.mappings)。`runtime:"unavailable"` 说的是
|
|
4
|
+
* 「这条运行面根本不执行它」,不是「执行了但结果不对」。
|
|
5
|
+
*/
|
|
6
|
+
export function verificationConfigOnly(surface, claim, next) {
|
|
7
|
+
return {
|
|
8
|
+
config: "verified",
|
|
9
|
+
runtime: "unavailable",
|
|
10
|
+
runtimeSurface: surface,
|
|
11
|
+
claim,
|
|
12
|
+
...(next !== undefined ? { next } : {}),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** 配置与运行面都已取证。只有真的跑了运行面验证才用它,不要拿写成功冒充。 */
|
|
16
|
+
export function verificationVerified(claim = "配置读回等价,运行面已取证。", surface = "rest") {
|
|
17
|
+
return { config: "verified", runtime: "verified", runtimeSurface: surface, claim };
|
|
18
|
+
}
|
|
19
|
+
/** 配置已落地,但运行面只完成了一部分(例如已发布、列未绑定,业务页不可见)。 */
|
|
20
|
+
export function verificationPartial(claim, next) {
|
|
21
|
+
return {
|
|
22
|
+
config: "verified",
|
|
23
|
+
runtime: "partial",
|
|
24
|
+
runtimeSurface: "published-form",
|
|
25
|
+
claim,
|
|
26
|
+
...(next !== undefined ? { next } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** 配置写成功,但本次没有任何运行面证据(别把它读成「已生效」)。 */
|
|
30
|
+
export function verificationUnverified(surface, claim, next) {
|
|
31
|
+
return {
|
|
32
|
+
config: "verified",
|
|
33
|
+
runtime: "unverified",
|
|
34
|
+
runtimeSurface: surface,
|
|
35
|
+
claim,
|
|
36
|
+
...(next !== undefined ? { next } : {}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=verification.js.map
|