@agimon-ai/po-workflow 0.0.0-alpha.150 → 0.0.0-alpha.152

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.
@@ -3213,7 +3213,6 @@ var WorkflowParserService = class {
3213
3213
  };
3214
3214
  //#endregion
3215
3215
  //#region src/services/jobIdentity/index.ts
3216
- const ALLOCATION_REQUIREMENTS_CHANGED = "Workflow allocation requirements changed.";
3217
3216
  const ALLOCATION_UPGRADE_REQUIRED = "The identity provider requires an explicit-allocation upgrade.";
3218
3217
  /** Same revision algorithm as persisted workflow configuration, based on the parsed effective definition. */
3219
3218
  function workflowDefinitionRevision(workflow) {
@@ -3274,28 +3273,28 @@ async function callProvider(call) {
3274
3273
  /** Shared pre-effects admission. Provider evidence cannot replace the requested graph or references. */
3275
3274
  async function admitWorkflowAllocation(options) {
3276
3275
  const requirements = structuredClone(options.requirements);
3277
- const issues = (0, _agimon_ai_po_core_workflow.validatePoWorkflowAssignments)(requirements, options.assignments);
3278
- if (issues.length) throw new Error(issues.map((issue) => issue.message).join(" "));
3279
- if (!requirements.roles.length) {
3280
- if (options.expected !== void 0) throw new Error(ALLOCATION_REQUIREMENTS_CHANGED);
3281
- return;
3282
- }
3283
- const assignments = structuredClone(options.assignments);
3284
- if (!options.workspaceId) throw new Error("Explicit allocation requires an admitted workspace.");
3285
- const matchesRequest = (value) => {
3286
- if (!(0, node_util.isDeepStrictEqual)(value.requirements, requirements)) throw new Error(ALLOCATION_REQUIREMENTS_CHANGED);
3287
- if (!(0, node_util.isDeepStrictEqual)(value.assignments, assignments)) throw new Error("Workflow allocation assignments changed.");
3288
- if (value.scope.workspaceId !== options.workspaceId) throw new Error("Workflow allocation workspace scope changed.");
3289
- };
3290
3276
  const resolver = options.resolver;
3291
3277
  if (options.expected !== void 0) {
3292
3278
  const expected = (0, _agimon_ai_po_core_workflow.parsePoWorkflowAllocation)(options.expected);
3293
- matchesRequest(expected);
3279
+ if (!(0, node_util.isDeepStrictEqual)(expected.assignments, options.assignments)) throw new Error("Workflow allocation assignments changed.");
3280
+ if (expected.scope.workspaceId !== options.workspaceId) throw new Error("Workflow allocation workspace scope changed.");
3281
+ const issues = (0, _agimon_ai_po_core_workflow.validatePoWorkflowAssignments)(requirements, Object.fromEntries(Object.entries(expected.assignments).filter(([role]) => requirements.roles.includes(role))));
3282
+ if (issues.length) throw new Error(`The edited workflow needs roles this run was not launched with. ${issues.map((issue) => issue.message).join(" ")} Launch a fresh run to assign them.`);
3294
3283
  if (!resolver?.revalidateAllocation) throw new Error(ALLOCATION_UPGRADE_REQUIRED);
3295
3284
  const refreshed = (0, _agimon_ai_po_core_workflow.parsePoWorkflowAllocation)(await callProvider(() => resolver.revalidateAllocation(structuredClone(expected))));
3296
3285
  if (!(0, node_util.isDeepStrictEqual)(refreshed, expected)) throw new Error("Pinned workflow allocation evidence changed.");
3297
3286
  return refreshed;
3298
3287
  }
3288
+ const issues = (0, _agimon_ai_po_core_workflow.validatePoWorkflowAssignments)(requirements, options.assignments);
3289
+ if (issues.length) throw new Error(issues.map((issue) => issue.message).join(" "));
3290
+ if (!requirements.roles.length) return void 0;
3291
+ const assignments = structuredClone(options.assignments);
3292
+ if (!options.workspaceId) throw new Error("Explicit allocation requires an admitted workspace.");
3293
+ const matchesRequest = (value) => {
3294
+ if (!(0, node_util.isDeepStrictEqual)(value.requirements, requirements)) throw new Error("Workflow allocation requirements changed.");
3295
+ if (!(0, node_util.isDeepStrictEqual)(value.assignments, assignments)) throw new Error("Workflow allocation assignments changed.");
3296
+ if (value.scope.workspaceId !== options.workspaceId) throw new Error("Workflow allocation workspace scope changed.");
3297
+ };
3299
3298
  if (!resolver?.allocate) throw new Error(ALLOCATION_UPGRADE_REQUIRED);
3300
3299
  const admitted = (0, _agimon_ai_po_core_workflow.parsePoWorkflowAllocation)(await callProvider(() => resolver.allocate({
3301
3300
  requirements: structuredClone(requirements),
@@ -3306,7 +3305,7 @@ async function admitWorkflowAllocation(options) {
3306
3305
  }
3307
3306
  /** Revalidates the exact run allocation at every attempt, never consulting legacy teams. */
3308
3307
  function createJobIdentityAdmission(options) {
3309
- return async ({ job, roles }) => {
3308
+ return async ({ roles }) => {
3310
3309
  const allocation = options.allocation;
3311
3310
  if (allocation === void 0) {
3312
3311
  if (roles) throw new Error("Role-bound execution requires an explicit workflow allocation.");
@@ -3324,7 +3323,6 @@ function createJobIdentityAdmission(options) {
3324
3323
  identity: { kind: "none" },
3325
3324
  allocation: current
3326
3325
  };
3327
- if (!current.requirements.groups.some((group) => group.job === job && group.roles.length === roles.length && roles.every((role) => group.roles.includes(role)))) throw new Error("Job roles do not match the captured workflow allocation.");
3328
3326
  const refs = new Set(roles.map((role) => current.assignments[role]));
3329
3327
  const ref = [...refs][0];
3330
3328
  if (refs.size !== 1 || ref === void 0) throw new Error("Job roles require one explicit profile reference.");
@@ -14043,4 +14041,4 @@ Object.defineProperty(exports, "workflowShellOutput", {
14043
14041
  }
14044
14042
  });
14045
14043
 
14046
- //# sourceMappingURL=RecoverWorkflowService-DJ9dzZmJ.cjs.map
14044
+ //# sourceMappingURL=RecoverWorkflowService-7-0W_pJg.cjs.map