@stalfh233/omc-fake-platform 0.6.84 → 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.
package/dist/index.d.ts CHANGED
@@ -42,6 +42,23 @@ export declare class FakeCloudPivot implements CloudPivotHttp {
42
42
  forceSubmitMissingObjectId: boolean;
43
43
  forceSubmitMismatchedObjectId: boolean;
44
44
  omitDraftSaveWorkItem: boolean;
45
+ /**
46
+ * r88(R88 提案 #2 扫描并发化):可控延迟注入——每个请求延迟该毫秒数,
47
+ * 用于测并发窗口的墙钟收益与 maxInFlight 观测(不竞态:延迟只 await,
48
+ * 状态仍单线程)。默认 0(不延迟)。
49
+ */
50
+ latencyMs: number;
51
+ /**
52
+ * r88:可控限流注入——前 `times` 个 path 含 fragment 的请求回 HTTP
53
+ * `status`(429/503/504),之后放行。用于测 CLI 的限流识别 + 一次抖动
54
+ * 退避重试 + 窗口降级(wire.concurrency.retries/effective)路径。
55
+ */
56
+ throttle: {
57
+ pathFragment: string;
58
+ status: number;
59
+ times: number;
60
+ } | null;
61
+ private throttleServed;
45
62
  constructor(options?: FakeCloudPivotOptions);
46
63
  /** Test accessor: the stored default-form draft for a schema (undefined if none). */
47
64
  sheetDraft(schemaCode: string): FakeSheet | undefined;
package/dist/index.js CHANGED
@@ -35,6 +35,19 @@ export class FakeCloudPivot {
35
35
  forceSubmitMissingObjectId = false;
36
36
  forceSubmitMismatchedObjectId = false;
37
37
  omitDraftSaveWorkItem = false;
38
+ /**
39
+ * r88(R88 提案 #2 扫描并发化):可控延迟注入——每个请求延迟该毫秒数,
40
+ * 用于测并发窗口的墙钟收益与 maxInFlight 观测(不竞态:延迟只 await,
41
+ * 状态仍单线程)。默认 0(不延迟)。
42
+ */
43
+ latencyMs = 0;
44
+ /**
45
+ * r88:可控限流注入——前 `times` 个 path 含 fragment 的请求回 HTTP
46
+ * `status`(429/503/504),之后放行。用于测 CLI 的限流识别 + 一次抖动
47
+ * 退避重试 + 窗口降级(wire.concurrency.retries/effective)路径。
48
+ */
49
+ throttle = null;
50
+ throttleServed = 0;
38
51
  constructor(options = {}) {
39
52
  this.options = options;
40
53
  this.state = createFakeState(options);
@@ -148,6 +161,16 @@ export class FakeCloudPivot {
148
161
  // 模拟)。放在 callLog 之后:下探链的「先打了主端点」仍可在日志里核对。
149
162
  if (this.absentPaths.has(input.path))
150
163
  return { status: 404, body: { errcode: 404, errmsg: "not found (absent endpoint — version family simulation)", data: null } };
164
+ // r88:限流注入优先于断路/业务注错——测的是调用方(CLI)的退避与降级,
165
+ // 不是 fake 自身的路由。
166
+ if (this.throttle !== null && this.throttleServed < this.throttle.times && input.path.includes(this.throttle.pathFragment)) {
167
+ this.throttleServed += 1;
168
+ if (this.latencyMs > 0)
169
+ await new Promise((resolve) => setTimeout(resolve, this.latencyMs));
170
+ return { status: this.throttle.status, body: { errcode: this.throttle.status, errmsg: "simulated throttle (rate-limit injection)", data: null } };
171
+ }
172
+ if (this.latencyMs > 0)
173
+ await new Promise((resolve) => setTimeout(resolve, this.latencyMs));
151
174
  if (this.transportDown)
152
175
  throw new Error("simulated transport outage");
153
176
  if (this.businessFailure && input.path.includes(this.businessFailure.pathFragment))
package/dist/workflow.js CHANGED
@@ -161,6 +161,41 @@ function toWorkItemVO(item) {
161
161
  sequenceNo: item.sequenceNo,
162
162
  };
163
163
  }
164
+ /**
165
+ * The converter both /update and /publish run (8.6 pins activityName/type/
166
+ * i18nMessage on an existing code; 1.1.x only threads name_i18n). Extracted so
167
+ * the published face gets the SAME treatment as the stored draft — a
168
+ * draft-vs-published diff must not see phantom drift the platform cannot
169
+ * produce.
170
+ */
171
+ function pinActivityIdentity(body, wf, pinsIdentity) {
172
+ if (!Array.isArray(body.activities))
173
+ return body;
174
+ const stored = wf.template.activities;
175
+ const storedByCode = new Map((Array.isArray(stored) ? stored : []).map((activity) => [String(activity.activityCode ?? ""), activity]));
176
+ return {
177
+ ...body,
178
+ activities: body.activities.map((activity) => {
179
+ const prior = storedByCode.get(String(activity.activityCode ?? ""));
180
+ if (!prior)
181
+ return activity;
182
+ // Pin without MATERIALIZING undefined keys: a key whose value is
183
+ // undefined must not appear at all (the real wire is JSON, which drops
184
+ // it), otherwise the two faces differ in key sets the platform cannot
185
+ // produce.
186
+ const pinned = { ...activity };
187
+ const fields = pinsIdentity ? ["activityName", "i18nMessage", "activityType", "name_i18n"] : ["name_i18n"];
188
+ for (const field of fields) {
189
+ const value = field === "name_i18n" ? (activity.name_i18n ?? prior.name_i18n) : prior[field];
190
+ if (value === undefined)
191
+ delete pinned[field];
192
+ else
193
+ pinned[field] = value;
194
+ }
195
+ return pinned;
196
+ }),
197
+ };
198
+ }
164
199
  /** W7-S29-greenfield lane: workflow template authoring + runtime work-item query. Twin of src/lanes/workflow.ts. */
165
200
  export const workflowRoute = (ctx, input) => {
166
201
  const q = input.query ?? {};
@@ -278,27 +313,12 @@ export const workflowRoute = (ctx, input) => {
278
313
  // `name_i18n` (locale map) is writable and is the rename carrier — the
279
314
  // designer's own rename posts exactly that under the same code. The fake
280
315
  // must pin the identity fields yet store name_i18n verbatim.
281
- const stored = wf.template.activities;
282
- const storedByCode = new Map((Array.isArray(stored) ? stored : []).map((activity) => [String(activity.activityCode ?? ""), activity]));
283
316
  // 8.6 pins activityName/type on an existing code; AI-Platform 1.1.x
284
317
  // accepts an in-place retype/rename on the SAME code (live 2026-10-21,
285
318
  // 1.1.25: END→PARTICIPANT kept Activity4 and read back with the new
286
319
  // name). The version switch keeps the fake faithful to both families.
287
320
  const pinsIdentity = !(String(ctx.options.version ?? "").startsWith("1."));
288
- const pinned = Array.isArray(body.activities)
289
- ? {
290
- ...body,
291
- activities: body.activities.map((activity) => {
292
- const prior = storedByCode.get(String(activity.activityCode ?? ""));
293
- if (!prior)
294
- return activity;
295
- return pinsIdentity
296
- ? { ...activity, activityName: prior.activityName, i18nMessage: prior.i18nMessage, activityType: prior.activityType, name_i18n: activity.name_i18n ?? prior.name_i18n }
297
- : { ...activity, name_i18n: activity.name_i18n ?? prior.name_i18n };
298
- }),
299
- }
300
- : body;
301
- wf.template = { ...pinned };
321
+ wf.template = { ...pinActivityIdentity(body, wf, pinsIdentity) };
302
322
  return { code };
303
323
  }
304
324
  case "/api/api/workflow/validate":
@@ -324,8 +344,19 @@ export const workflowRoute = (ctx, input) => {
324
344
  return validation;
325
345
  // Ticket 77: the published face carries the PUBLISH marker (live readback
326
346
  // evidence: publish state is identified by templateType:PUBLISH /
327
- // version fields, never by data presence).
328
- wf.published = { ...body, templateType: "PUBLISH", workflowVersion: (wf.published ? Number(wf.published.workflowVersion ?? 1) : 0) + 1 };
347
+ // version fields, never by data presence). The body runs through the
348
+ // SAME identity pinning the update applies — on the real platform both
349
+ // faces pass one converter, so draft and published carry the same
350
+ // i18nMessage/name_i18n treatment (a draft-vs-published diff must not
351
+ // see phantom drift the platform cannot produce).
352
+ wf.published = {
353
+ // DEEP copy: the stored faces must not share nested arrays/objects, or a
354
+ // later draft edit would silently mutate the published face too and the
355
+ // draft↔published diff would see nothing.
356
+ ...JSON.parse(JSON.stringify(pinActivityIdentity(body, wf, !(String(ctx.options.version ?? "").startsWith("1."))))),
357
+ templateType: "PUBLISH",
358
+ workflowVersion: (wf.published ? Number(wf.published.workflowVersion ?? 1) : 0) + 1,
359
+ };
329
360
  return { code, workflowVersion: wf.published.workflowVersion };
330
361
  }
331
362
  case "/api/api/workflow/list_permission": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-fake-platform",
3
- "version": "0.6.84",
3
+ "version": "0.6.85",
4
4
  "description": "OMC 的内存假 CloudPivot 平台(wire 接缝的第二个适配器)+ HTTP 假服务器——@stalfh233/omc-cli 的测试与 bench 基准基座",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "build": "tsc --project tsconfig.build.json"
19
19
  },
20
20
  "dependencies": {
21
- "omc-core": "0.6.84"
21
+ "omc-core": "0.6.85"
22
22
  },
23
23
  "engines": {
24
24
  "node": ">=22.13"