bpmax-cli 0.2.1-beta.40 → 0.2.1-beta.41

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/README.md CHANGED
@@ -138,7 +138,7 @@ bpmax-cli step actions 15690 --project-id 13097 --format json
138
138
  bpmax-cli step requirements 15690 --project-id 13097 --format json
139
139
  ```
140
140
 
141
- `step context` reports the project/step URL, current user ownership, parsed actions, current-step input requirements, form evidence, and `identity_unverified`. `step requirements` focuses on current-step bound form fields, required inputs, existing values, missing required inputs, and a submit payload template. If project and step form values are empty, do not advance from an ES keyword or attachment-text match alone.
141
+ `step context` reports the project/step URL, current user ownership, parsed actions, current-step input requirements, form evidence, and `identity_unverified`. Owner/assignee fields are authoritative for processability; `step.user_id` is diagnostic-only and cannot override a conflicting owner. `step requirements` focuses on current-step bound form fields, required inputs, existing values, missing required inputs, and a submit payload template. If project and step form values are empty, do not advance from an ES keyword or attachment-text match alone.
142
142
 
143
143
  Submit step actions through a dry-run first:
144
144
 
package/dist/bin.js CHANGED
@@ -496,7 +496,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
496
496
  // package.json
497
497
  var package_default = {
498
498
  name: "bpmax-cli",
499
- version: "0.2.1-beta.40",
499
+ version: "0.2.1-beta.41",
500
500
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
501
501
  type: "module",
502
502
  bin: {
@@ -6684,6 +6684,8 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
6684
6684
  return;
6685
6685
  }
6686
6686
  const dataSourceText = typeof dataSource === "string" ? dataSource : JSON.stringify(dataSource) ?? "";
6687
+ const customDataSourceCode = dataSourceText.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/\/\/[^\r\n]*/g, " ");
6688
+ const hasCustomBpmaxServerPagination = /['"]?driver['"]?\s*:\s*['"]custom_bpmax['"]/i.test(customDataSourceCode) && /\bsearch_after\b/i.test(customDataSourceCode) && /\bpage(?:Size|_size)?\b/i.test(customDataSourceCode) && /\.slice\s*\(/i.test(customDataSourceCode) && /\brows\b/i.test(customDataSourceCode) && /\btotal\b/i.test(customDataSourceCode);
6687
6689
  const stripJsNonCode = (text5) => {
6688
6690
  let output = "";
6689
6691
  let state = "code";
@@ -6931,7 +6933,7 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
6931
6933
  if (name === "offset") return safeConstExpression(expression, offsetSource);
6932
6934
  return false;
6933
6935
  });
6934
- const hasServerPagination = hasControlledFrom && hasControlledSize && hasOnlyConstPaginationPrefix && hasTrustedCfgBinding && hasCanonicalPaginationDeclarations && uniqueField("track_total_hits").toLowerCase() === "true" && hasTrustedHitsBinding && hasTrustedTotalBinding && hasReadonlyFrontendInputs && hasOnlyTrustedResultMap && !hasDisallowedFrontendLoop;
6936
+ const hasServerPagination = hasCustomBpmaxServerPagination || hasControlledFrom && hasControlledSize && hasOnlyConstPaginationPrefix && hasTrustedCfgBinding && hasCanonicalPaginationDeclarations && uniqueField("track_total_hits").toLowerCase() === "true" && hasTrustedHitsBinding && hasTrustedTotalBinding && hasReadonlyFrontendInputs && hasOnlyTrustedResultMap && !hasDisallowedFrontendLoop;
6935
6937
  if (hasFrontendDetailAccess && hasMetric && !hasAggregation && !hasServerPagination) {
6936
6938
  errors.push(`${moduleLabel} \u7981\u6B62\u62C9\u5168\u91CF\u660E\u7EC6\u5230\u524D\u7AEF\u9010\u884C\u7EDF\u8BA1\uFF1B\u7EDF\u8BA1\u7C7B\u770B\u677F\u5FC5\u987B\u4F7F\u7528 ES size: 0 + aggs/aggregations\u3002`);
6937
6939
  }
@@ -16775,7 +16777,8 @@ var REQUIRED_README_KEYS = ["scenario_id", "workspace", "flow_type", "core", "st
16775
16777
  var PRIORITIES = /* @__PURE__ */ new Set(["P0", "P1", "P2"]);
16776
16778
  var CASE_TYPES = /* @__PURE__ */ new Set(["positive", "negative", "boundary", "permission", "data_consistency", "regression"]);
16777
16779
  var STATUSES = /* @__PURE__ */ new Set(["active", "deprecated", "draft"]);
16778
- var CASE_STEP_RUNNERS = /* @__PURE__ */ new Set(["browser", "e2e_create_page", "e2e_step_run", "observe"]);
16780
+ var CASE_STEP_RUNNERS = /* @__PURE__ */ new Set(["browser", "identity", "e2e_create_page", "e2e_step_run", "observe"]);
16781
+ var IDENTITY_STEP_RE = /(?:切换|恢复|检查|核对|验证).{0,12}(?:身份|用户|管理员)|(?:mock|unmock|模拟用户)/i;
16779
16782
  var CASE_STEP_ACTION_VERBS = [
16780
16783
  "\u6253\u5F00",
16781
16784
  "\u8FDB\u5165",
@@ -17393,6 +17396,28 @@ function validateCaseSteps(filePath, cases, steps) {
17393
17396
  if (step.runner === "e2e_step_run" && !/(context|submit|readback|step)/i.test(step.evidence_required)) {
17394
17397
  fail(`${location}: e2e_step_run \u6B65\u9AA4\u5FC5\u987B\u8981\u6C42 context/submit/readback \u8BC1\u636E`, { rule_id: "test_suite.case_step.cli_evidence", path: filePath });
17395
17398
  }
17399
+ const identityStepText = [step.action, step.target, step.input_data, step.expected_result].join(" ");
17400
+ if (step.runner === "e2e_step_run" && IDENTITY_STEP_RE.test(identityStepText)) {
17401
+ fail(`${location}: identity mock/status/unmock \u4E0D\u80FD\u58F0\u660E\u4E3A e2e_step_run\uFF1B\u8BF7\u4F7F\u7528 runner=identity`, {
17402
+ rule_id: "test_suite.case_step.identity_runner",
17403
+ path: filePath,
17404
+ suggestion: "Set runner=identity and require identity operation plus readback evidence."
17405
+ });
17406
+ }
17407
+ if (step.runner === "identity") {
17408
+ if (!IDENTITY_STEP_RE.test(identityStepText)) {
17409
+ fail(`${location}: runner=identity \u53EA\u80FD\u7528\u4E8E\u8EAB\u4EFD mock/status/unmock \u6B65\u9AA4`, {
17410
+ rule_id: "test_suite.case_step.identity_action",
17411
+ path: filePath
17412
+ });
17413
+ }
17414
+ if (!/(identity|mock|unmock|身份)/i.test(step.evidence_required) || !/(readback|status|回读|恢复)/i.test(step.evidence_required)) {
17415
+ fail(`${location}: identity \u6B65\u9AA4\u5FC5\u987B\u8981\u6C42 identity operation \u548C readback/status \u8BC1\u636E`, {
17416
+ rule_id: "test_suite.case_step.identity_evidence",
17417
+ path: filePath
17418
+ });
17419
+ }
17420
+ }
17396
17421
  const values = grouped.get(caseId) ?? [];
17397
17422
  values.push(step);
17398
17423
  grouped.set(caseId, values);
@@ -17613,7 +17638,7 @@ async function migrateScenarioSteps(options) {
17613
17638
  step_id: stepId,
17614
17639
  step_no: String(index + 1),
17615
17640
  actor: roles.length === 1 ? roles[0] : "REVIEW_REQUIRED",
17616
- runner: /发起|创建/.test(action) ? "e2e_create_page" : /审批|驳回|回退|处理/.test(action) ? "e2e_step_run" : "browser",
17641
+ runner: IDENTITY_STEP_RE.test(action) ? "identity" : /发起|创建/.test(action) ? "e2e_create_page" : /审批|驳回|回退|处理/.test(action) ? "e2e_step_run" : "browser",
17617
17642
  action,
17618
17643
  target: "REVIEW_REQUIRED",
17619
17644
  input_data: "REVIEW_REQUIRED",
@@ -18055,6 +18080,24 @@ async function assertFormalExecutionEvidence(manifest, manifestPath, step, evide
18055
18080
  if (step.runner === "e2e_step_run" && !/"?status"?\s*:\s*"submitted"|"?operation_executed"?\s*:\s*true/i.test(joined)) {
18056
18081
  fail("e2e_step_run pass evidence must prove a confirmed submitted operation", { rule_id: "test_suite.run.unexecuted_evidence", path: evidencePath });
18057
18082
  }
18083
+ if (step.runner === "identity") {
18084
+ const validIdentityEvidence = jsonRecords.some(({ value }) => {
18085
+ const operation = String(value.operation || "").toLowerCase();
18086
+ if (operation === "status") {
18087
+ return ["observed", "verified"].includes(String(value.result || value.status || "").toLowerCase()) && Object.keys(asRecord(value.current_user)).length > 0;
18088
+ }
18089
+ if (operation === "mock" || operation === "unmock") {
18090
+ return value.operation_executed === true && value.remote_submitted === true && value.readback_confirmed === true;
18091
+ }
18092
+ return false;
18093
+ });
18094
+ if (!validIdentityEvidence) {
18095
+ fail("identity pass evidence must prove status readback or a confirmed mock/unmock operation", {
18096
+ rule_id: "test_suite.run.unexecuted_evidence",
18097
+ path: evidencePath
18098
+ });
18099
+ }
18100
+ }
18058
18101
  if (step.runner === "browser" || step.runner === "e2e_create_page") {
18059
18102
  const screenshots = await browserEvidenceScreenshots(manifest, manifestPath, step, evidencePath);
18060
18103
  const previousHashes = await previousBrowserScreenshotHashes(manifest, step);
@@ -20271,8 +20314,6 @@ function ownerIdsFromStep(step) {
20271
20314
  const owners = [
20272
20315
  step.owner_id,
20273
20316
  step.ownerId,
20274
- step.user_id,
20275
- step.userId,
20276
20317
  ...Array.isArray(step.owners) ? step.owners : [],
20277
20318
  ...Array.isArray(step.owner_list) ? step.owner_list : [],
20278
20319
  ...Array.isArray(step.step_owners) ? step.step_owners : []
@@ -20294,19 +20335,23 @@ function ownerIdsFromStep(step) {
20294
20335
  return [...ids];
20295
20336
  }
20296
20337
  function ownerDiagnosticsFromStep(step, currentUser) {
20297
- const sources = [
20338
+ const authoritativeSources = [
20298
20339
  { source: "owner_id", value: step.owner_id },
20299
20340
  { source: "ownerId", value: step.ownerId },
20300
- { source: "user_id", value: step.user_id },
20301
- { source: "userId", value: step.userId },
20302
20341
  { source: "owners", value: step.owners },
20303
20342
  { source: "owner_list", value: step.owner_list },
20304
20343
  { source: "step_owners", value: step.step_owners }
20305
20344
  ];
20345
+ const auxiliarySources = [
20346
+ { source: "user_id", value: step.user_id },
20347
+ { source: "userId", value: step.userId }
20348
+ ];
20306
20349
  const ownerIds = /* @__PURE__ */ new Set();
20307
20350
  const ownerSources = /* @__PURE__ */ new Set();
20351
+ const auxiliaryUserIds = /* @__PURE__ */ new Set();
20352
+ const auxiliarySourceNames = /* @__PURE__ */ new Set();
20308
20353
  const emptyOwnerArrays = [];
20309
- for (const { source, value } of sources) {
20354
+ for (const { source, value } of authoritativeSources) {
20310
20355
  if (Array.isArray(value) && value.length === 0) {
20311
20356
  emptyOwnerArrays.push(source);
20312
20357
  }
@@ -20324,14 +20369,25 @@ function ownerDiagnosticsFromStep(step, currentUser) {
20324
20369
  }
20325
20370
  }
20326
20371
  }
20372
+ for (const { source, value } of auxiliarySources) {
20373
+ const id = idValue(value);
20374
+ if (id) {
20375
+ auxiliaryUserIds.add(id);
20376
+ auxiliarySourceNames.add(source);
20377
+ }
20378
+ }
20327
20379
  const currentUserId = currentUser ? idValue(currentUser.id ?? currentUser.user_id ?? currentUser.owner_id) : void 0;
20380
+ const sourceConflict = ownerIds.size > 0 && [...auxiliaryUserIds].some((id) => !ownerIds.has(id));
20328
20381
  return {
20329
20382
  explicit_owner_ids: [...ownerIds],
20330
20383
  owner_sources: [...ownerSources],
20384
+ auxiliary_user_ids: [...auxiliaryUserIds],
20385
+ auxiliary_sources: [...auxiliarySourceNames],
20331
20386
  ...currentUserId ? { current_user_id: currentUserId } : {},
20332
20387
  current_user_matched_explicit_owner: currentUserId ? ownerIds.has(currentUserId) : null,
20388
+ source_conflict: sourceConflict,
20333
20389
  empty_owner_arrays: emptyOwnerArrays,
20334
- ...ownerIds.size === 0 ? { note: "No explicit step owner ids were returned; processability may come from admin fallback, permission fallback, or unresolved matrix owner behavior." } : {}
20390
+ ...ownerIds.size === 0 ? { note: auxiliaryUserIds.size > 0 ? "Only auxiliary step.user_id data was returned; it is not sufficient proof that the current user can process this step." : "No explicit step owner ids were returned; processability may come from admin fallback, permission fallback, or unresolved matrix owner behavior." } : {}
20335
20391
  };
20336
20392
  }
20337
20393
  function checkCurrentUserCanProcess(step, currentUser) {
@@ -20351,7 +20407,7 @@ function checkCurrentUserCanProcess(step, currentUser) {
20351
20407
  }
20352
20408
  return {
20353
20409
  current_user_can_process: ownerIds.includes(currentUserId),
20354
- current_user_reason: ownerIds.includes(currentUserId) ? "Current user is listed as a step owner." : "Current user is not listed as a step owner."
20410
+ current_user_reason: ownerIds.includes(currentUserId) ? "Current user is listed as an authoritative step owner." : "Current user is not listed as an authoritative step owner."
20355
20411
  };
20356
20412
  }
20357
20413
  async function buildStepContext(profile, client, stepId, projectId) {
@@ -20531,7 +20587,7 @@ function registerStepCommands(program2) {
20531
20587
  if (context2.step_finished) {
20532
20588
  throw new Error("Refusing to submit: step appears to be finished.");
20533
20589
  }
20534
- if (context2.current_user_can_process === false) {
20590
+ if (context2.current_user_can_process !== true) {
20535
20591
  throw new Error(`Refusing to submit: ${context2.current_user_reason}`);
20536
20592
  }
20537
20593
  if (!requirements.can_submit) {
@@ -20787,7 +20843,9 @@ function expectationTarget(context2, requirements) {
20787
20843
  current_user_reason: context2.current_user_reason,
20788
20844
  actions: context2.actions.map((action) => action.action),
20789
20845
  action_labels: context2.actions.map((action) => action.label),
20790
- owner_sources: context2.owner_diagnostics.owner_sources
20846
+ owner_sources: context2.owner_diagnostics.owner_sources,
20847
+ auxiliary_owner_sources: context2.owner_diagnostics.auxiliary_sources,
20848
+ owner_source_conflict: context2.owner_diagnostics.source_conflict
20791
20849
  },
20792
20850
  requirements: {
20793
20851
  can_submit: requirements.can_submit,
@@ -20978,6 +21036,9 @@ function blockedReason(context2, canSubmit) {
20978
21036
  if (context2.current_user_can_process === false) {
20979
21037
  return "current_user_cannot_process";
20980
21038
  }
21039
+ if (context2.current_user_can_process === null) {
21040
+ return "step_owner_unverified";
21041
+ }
20981
21042
  if (!canSubmit) {
20982
21043
  return "missing_required_step_inputs";
20983
21044
  }
@@ -21066,7 +21127,7 @@ function registerE2eCommands(program2) {
21066
21127
  const identity = e2e.command("identity").description("Control browser-session mock identity for formal multi-role E2E");
21067
21128
  const addIdentityOptions = (command) => command.requiredOption("--evidence-dir <dir>", "Current-run identity evidence directory").option("--execution-manifest <file>", "Formal test-suite execution manifest").option("--case-id <id>", "Formal test-suite case id").option("--case-step-id <id>", "Formal test-suite case step id").option("--diagnostic", "Run without a formal manifest; cannot become pass evidence").option("--profile <profile>", "Profile providing origin and workspace").option("--cookie-env <name>", "Environment variable containing current browser Cookie", "BPMAX_COOKIE_HEADER").option("--href-path <path>", "BPMAX page path used for Referer and x-href").option("--format <format>", "Output format", "json");
21068
21129
  addIdentityOptions(identity.command("status").description("Read and record current browser-session identity")).action(async (options) => {
21069
- await requireE2eExecutionBinding(options, ["browser", "observe"], options.evidenceDir);
21130
+ await requireE2eExecutionBinding(options, ["identity", "browser", "observe"], options.evidenceDir);
21070
21131
  const config = await loadConfig();
21071
21132
  const profile = resolveProfile(config, options.profile);
21072
21133
  const current = safeIdentity(await browserSessionRequest(
@@ -21084,7 +21145,7 @@ function registerE2eCommands(program2) {
21084
21145
  remote_submitted: false,
21085
21146
  current_user: current
21086
21147
  });
21087
- await appendE2eExecutionEvidence(options, evidence, ["browser", "observe"]);
21148
+ await appendE2eExecutionEvidence(options, evidence, ["identity", "browser", "observe"]);
21088
21149
  printResult(options.format, {
21089
21150
  ok: true,
21090
21151
  result: options.diagnostic ? "diagnostic" : "observed",
@@ -21098,7 +21159,7 @@ function registerE2eCommands(program2) {
21098
21159
  if (!Number.isSafeInteger(userId) || userId <= 0) {
21099
21160
  throw new Error("e2e.identity.invalid_user_id: --user-id \u5FC5\u987B\u662F\u6B63\u6574\u6570\u3002");
21100
21161
  }
21101
- await requireE2eExecutionBinding(options, ["browser"], options.evidenceDir);
21162
+ await requireE2eExecutionBinding(options, ["identity", "browser"], options.evidenceDir);
21102
21163
  const config = await loadConfig();
21103
21164
  const profile = resolveProfile(config, options.profile);
21104
21165
  const cookie = identityCookie(options.cookieEnv);
@@ -21147,7 +21208,7 @@ function registerE2eCommands(program2) {
21147
21208
  throw new Error(`e2e.identity.evidence_failed: mock \u540E\u8BC1\u636E\u5199\u5165\u5931\u8D25\uFF0C\u5DF2\u5C1D\u8BD5\u6062\u590D\u539F\u8EAB\u4EFD\u3002${error instanceof Error ? error.message : String(error)}`);
21148
21209
  }
21149
21210
  try {
21150
- await appendE2eExecutionEvidence(options, evidence, ["browser"]);
21211
+ await appendE2eExecutionEvidence(options, evidence, ["identity", "browser"]);
21151
21212
  } catch (error) {
21152
21213
  await browserSessionRequest(profile, cookie, "PUT", "/user/current?identity_action=unmock", { unmock: true }, options.hrefPath).catch(() => void 0);
21153
21214
  throw new Error(`e2e.identity.manifest_evidence_failed: mock \u5DF2\u6267\u884C\u4F46\u7528\u4F8B\u8BC1\u636E\u767B\u8BB0\u5931\u8D25\uFF0CCLI \u5DF2\u5C1D\u8BD5\u81EA\u52A8 unmock\u3002${error instanceof Error ? error.message : String(error)}`);
@@ -21165,7 +21226,7 @@ function registerE2eCommands(program2) {
21165
21226
  });
21166
21227
  });
21167
21228
  addIdentityOptions(identity.command("unmock").description("Restore the original browser-session identity and verify recovery")).action(async (options) => {
21168
- await requireE2eExecutionBinding(options, ["browser"], options.evidenceDir);
21229
+ await requireE2eExecutionBinding(options, ["identity", "browser"], options.evidenceDir);
21169
21230
  const config = await loadConfig();
21170
21231
  const profile = resolveProfile(config, options.profile);
21171
21232
  const cookie = identityCookie(options.cookieEnv);
@@ -21188,7 +21249,7 @@ function registerE2eCommands(program2) {
21188
21249
  before,
21189
21250
  after
21190
21251
  });
21191
- await appendE2eExecutionEvidence(options, evidence, ["browser"]);
21252
+ await appendE2eExecutionEvidence(options, evidence, ["identity", "browser"]);
21192
21253
  printResult(options.format, {
21193
21254
  ok: true,
21194
21255
  result: options.diagnostic ? "diagnostic" : "restored",