assignment-user-matcher 1.3.0 → 1.6.0

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.
@@ -1,8 +1,8 @@
1
1
  import { type PaginationOptions, type PaginationResult, type AssignmentCounts } from './queries/pagination';
2
2
  import { type WorkflowHost, type MachineTaskHandler } from './managers/WorkflowManager';
3
- import type { RedisClientType, User, Assignment, Stats, PendingAssignmentInfo, QueueStats, MatcherOptions, WorkflowDefinition, WorkflowDefinitionInput, WorkflowDefinitionSummary, WorkflowInstance, WorkflowEvent, AssignmentResult, DeadLetterEntry, AuditEntry, WorkflowInstanceWithSnapshot, LearningSignals, LearningSample, LearningStats, LearningTagStat, ReliabilityMetrics, CircuitBreakerState, WorkflowEngineMetrics, FairnessMode, FairnessConfig, MatchDecisionTrace, MatchExplanation, DecisionTraceQuery } from './types/matcher';
4
- export type { RedisClientType, User, Assignment, Stats, PendingAssignmentInfo, QueueStats, UserLoadInfo, MatcherOptions, options, FairnessMode, FairnessConfig, GeoMatchResult, GeoMatchingFunction, ReliabilityMetrics, WorkflowInstanceStatus, WorkflowRouting, MatchTraceReason, MatchCandidateTrace, MatchDecisionTrace, MatchDecisionMode, MatchExplanation, DecisionTraceQuery, } from './types/matcher';
5
- export type { WorkflowDefinition, WorkflowDefinitionInput, WorkflowDefinitionSummary, WorkflowInstance, WorkflowStep, WorkflowTargetUser, WorkflowMachineTask, WorkflowTaskType, WorkflowEvent, WorkflowEventType, AssignmentResult, ParallelBranchState, DeadLetterEntry, AuditEntry, CircuitBreakerState, WorkflowInstanceWithSnapshot, LearningOutcome, LearningRewards, LearningFeatures, LearningAssignmentContext, LearningFeatureExtractor, LearningDecisionRecord, LearningEpisodeRecord, LearningSignals, LearningSample, LearningStats, LearningTagStat, AutoRoutingWeightsOptions, WorkflowEngineMetrics, } from './types/matcher';
3
+ import type { RedisClientType, User, Assignment, Stats, PendingAssignmentInfo, QueueStats, MatcherOptions, WorkflowDefinition, WorkflowDefinitionInput, WorkflowDefinitionSummary, WorkflowInstance, WorkflowEvent, AssignmentResult, DeadLetterEntry, AuditEntry, WorkflowInstanceWithSnapshot, WorkflowInstanceQuery, WorkflowInstancePage, LearningSignals, LearningSample, LearningStats, LearningTagStat, ReliabilityMetrics, CircuitBreakerState, WorkflowEngineMetrics, FairnessMode, FairnessConfig, MatchDecisionTrace, MatchExplanation, MatchPreview, MatchPreviewInput, DecisionTraceQuery } from './types/matcher';
4
+ export type { RedisClientType, User, Assignment, Stats, PendingAssignmentInfo, QueueStats, UserLoadInfo, MatcherOptions, options, FairnessMode, FairnessConfig, GeoMatchResult, GeoMatchingFunction, ReliabilityMetrics, WorkflowInstanceStatus, WorkflowRouting, MatchTraceReason, MatchCandidateTrace, MatchDecisionTrace, MatchDecisionMode, MatchExplanation, MatchPreview, MatchPreviewInput, DecisionTraceQuery, AssignmentLifecycleEvent, } from './types/matcher';
5
+ export type { WorkflowDefinition, WorkflowDefinitionInput, WorkflowDefinitionSummary, WorkflowInstance, WorkflowStep, WorkflowTargetUser, WorkflowMachineTask, WorkflowExternalTask, WorkflowTaskType, WorkflowEvent, WorkflowEventType, AssignmentResult, ParallelBranchState, DeadLetterEntry, AuditEntry, CircuitBreakerState, WorkflowInstanceWithSnapshot, WorkflowInstanceQuery, WorkflowInstancePage, WorkflowTransition, LearningOutcome, LearningRewards, LearningFeatures, LearningAssignmentContext, LearningFeatureExtractor, LearningDecisionRecord, LearningEpisodeRecord, LearningSignals, LearningSample, LearningStats, LearningTagStat, AutoRoutingWeightsOptions, WorkflowEngineMetrics, } from './types/matcher';
6
6
  export type { MachineTaskHandler, WorkflowHost } from './managers/WorkflowManager';
7
7
  export type { AssignmentStatus, PaginationOptions, PaginationResult, AssignmentCounts } from './queries/pagination';
8
8
  export default class AssignmentMatcher implements WorkflowHost {
@@ -49,7 +49,13 @@ export default class AssignmentMatcher implements WorkflowHost {
49
49
  private enableDecisionTraces;
50
50
  private decisionTraceMaxCandidates;
51
51
  private decisionTraces;
52
+ private onAssignmentLifecycle?;
52
53
  constructor(redisClient: RedisClientType, options?: MatcherOptions);
54
+ /**
55
+ * Fire the optional assignment lifecycle hook. Errors are swallowed so a
56
+ * slow/failing observer can never break a lifecycle transition.
57
+ */
58
+ private emitAssignmentLifecycle;
53
59
  /** Keys for the three assignment stores (used by pagination queries) */
54
60
  private get assignmentStoreKeys();
55
61
  private initRedis;
@@ -218,6 +224,20 @@ export default class AssignmentMatcher implements WorkflowHost {
218
224
  }): Promise<MatchExplanation>;
219
225
  /** One user's full eligibility/score evaluation for explainMatch(). */
220
226
  private explainCandidate;
227
+ /**
228
+ * Shared eligibility/scoring evaluation used by explainMatch() and
229
+ * previewMatch(). Read-only: never claims, writes, or records decisions.
230
+ */
231
+ private evaluateCandidateForAssignment;
232
+ /**
233
+ * Preview which users would be candidates for a hypothetical assignment
234
+ * without creating it or claiming anything. Uses the same scoring, hard
235
+ * rules, and learning re-ranking as real matching, so the ranked result
236
+ * matches what `explainMatch()` would report if the assignment were added.
237
+ */
238
+ previewMatch(input: MatchPreviewInput, opts?: {
239
+ userIds?: string[];
240
+ }): Promise<MatchPreview>;
221
241
  /** Build and record this pass's decision traces; failures never break matching. */
222
242
  private recordPassTraces;
223
243
  /** Exclusion sets used to enrich traces with prefiltered (vetoed/rejected/paused) users. */
@@ -285,6 +305,12 @@ export default class AssignmentMatcher implements WorkflowHost {
285
305
  * 'default' tag when enableDefaultMatching is on), or null.
286
306
  */
287
307
  getUser(userId: string): Promise<User | null>;
308
+ /**
309
+ * Whether a user is registered in the pool. Used by the workflow engine
310
+ * (via the WorkflowHost interface) to validate an initiator before
311
+ * starting a run that targets 'initiator'.
312
+ */
313
+ userExists(userId: string): Promise<boolean>;
288
314
  /** All stored users. The pool is small by design; for load metadata see getQueueStats(). */
289
315
  getUsers(): Promise<User[]>;
290
316
  /**
@@ -304,6 +330,16 @@ export default class AssignmentMatcher implements WorkflowHost {
304
330
  * @returns false when the user was not paused
305
331
  */
306
332
  resumeUser(userId: string): Promise<boolean>;
333
+ /**
334
+ * Requeue every pending (matched but not yet accepted) assignment the user
335
+ * holds so other users can pick them up — the operator's "this person is
336
+ * gone, redistribute their work" move, typically paired with `pauseUser`
337
+ * (which alone deliberately preserves the backlog). Accepted assignments
338
+ * (work in progress) are never touched. Requeued assignments keep their
339
+ * original wait clock, and a still-paused user won't win them back until
340
+ * resumed. Returns the released assignment ids ([] when nothing was held).
341
+ */
342
+ releaseUserAssignments(userId: string): Promise<string[]>;
307
343
  /** Whether a user is currently paused. */
308
344
  isUserPaused(userId: string): Promise<boolean>;
309
345
  /** IDs of all currently paused users. */
@@ -509,15 +545,38 @@ export default class AssignmentMatcher implements WorkflowHost {
509
545
  * Get all active workflow instances for a user.
510
546
  */
511
547
  getActiveWorkflowsForUser(userId: string): Promise<WorkflowInstance[]>;
548
+ /**
549
+ * List workflow instances (runs), newest-created first, optionally
550
+ * filtered by status and/or workflow definition. Paginated via an opaque
551
+ * cursor from the previous page's `nextCursor`.
552
+ */
553
+ listWorkflowInstances(query?: WorkflowInstanceQuery): Promise<WorkflowInstancePage>;
512
554
  /**
513
555
  * Cancel a workflow instance.
514
556
  */
515
557
  cancelWorkflow(instanceId: string): Promise<boolean>;
558
+ /**
559
+ * Complete (or fail, via `outcome.success: false`) an external step from
560
+ * outside this process — the counterpart to the `step.ready` transition
561
+ * delivered via `onWorkflowEvent`. Throws if the step isn't the run's
562
+ * current step (or a pending parallel branch) or isn't an external step.
563
+ */
564
+ completeWorkflowStep(instanceId: string, stepId: string, outcome: {
565
+ success: boolean;
566
+ data?: Record<string, any>;
567
+ error?: string;
568
+ }): Promise<boolean>;
516
569
  /**
517
570
  * Check and process expired workflow steps.
518
571
  * Should be called periodically.
519
572
  */
520
573
  processExpiredWorkflowSteps(): Promise<number>;
574
+ /**
575
+ * Non-blocking drain of up to `maxEvents` due workflow events. Intended
576
+ * for hosts that sweep many matcher instances periodically rather than
577
+ * running `startOrchestrator()`'s dedicated blocking loop per instance.
578
+ */
579
+ processWorkflowEvents(maxEvents?: number): Promise<number>;
521
580
  /**
522
581
  * Publish a workflow event to the Redis Stream.
523
582
  */
@@ -1 +1 @@
1
- {"version":3,"file":"matcher.class.d.ts","sourceRoot":"","sources":["../src/matcher.class.ts"],"names":[],"mappings":"AAMA,OAAO,EAMH,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACxB,MAAM,sBAAsB,CAAC;AAe9B,OAAO,EAAmB,KAAK,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACzG,OAAO,KAAK,EACR,eAAe,EACf,IAAI,EACJ,UAAU,EACV,KAAK,EACL,qBAAqB,EACrB,UAAU,EAEV,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,4BAA4B,EAI5B,eAAe,EACf,cAAc,EACd,aAAa,EACb,eAAe,EAGf,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,cAAc,EAGd,kBAAkB,EAElB,gBAAgB,EAChB,kBAAkB,EACrB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACR,eAAe,EACf,IAAI,EACJ,UAAU,EACV,KAAK,EACL,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,OAAO,EACP,YAAY,EACZ,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EACR,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,gBA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;;OAEG;YACW,6BAA6B;IAiD3C,OAAO,CAAC,gBAAgB,CAA+B;IAEvD,qBAAqB,CAAC,UAAU,GAAE,MAAc;IAOhD,oBAAoB;IAOpB;;;OAGG;YACW,8BAA8B;YA6B9B,kBAAkB;CAwBnC"}
@@ -124,9 +124,25 @@ class AssignmentMatcher {
124
124
  eventBatchSize: options?.workflowEventBatchSize,
125
125
  pollBlockMs: options?.workflowPollBlockMs,
126
126
  maxEventsPerSecond: options?.workflowMaxEventsPerSecond,
127
+ onWorkflowEvent: options?.onWorkflowEvent,
127
128
  });
129
+ this.onAssignmentLifecycle = options?.onAssignmentLifecycle;
128
130
  this.readyPromise = this.initRedis();
129
131
  }
132
+ /**
133
+ * Fire the optional assignment lifecycle hook. Errors are swallowed so a
134
+ * slow/failing observer can never break a lifecycle transition.
135
+ */
136
+ emitAssignmentLifecycle(event) {
137
+ if (!this.onAssignmentLifecycle)
138
+ return;
139
+ try {
140
+ this.onAssignmentLifecycle(event);
141
+ }
142
+ catch (err) {
143
+ // Best-effort hook: do not propagate.
144
+ }
145
+ }
130
146
  /** Keys for the three assignment stores (used by pagination queries) */
131
147
  get assignmentStoreKeys() {
132
148
  return {
@@ -506,17 +522,35 @@ class AssignmentMatcher {
506
522
  }
507
523
  /** One user's full eligibility/score evaluation for explainMatch(). */
508
524
  async explainCandidate(user, assignment, assignmentId, tagsCsv, basePriority, ownerId, modelWeights) {
525
+ const [isRejected, backlog, isPaused] = await Promise.all([
526
+ this.redisClient.sIsMember(this.keys.userRejected(user.id), assignmentId),
527
+ this.redisClient.sCard(this.keys.userAssignments(user.id)),
528
+ this.redisClient.sIsMember(this.keys.pausedUsers(), user.id),
529
+ ]);
530
+ return this.evaluateCandidateForAssignment(user, assignment, tagsCsv, basePriority, modelWeights, {
531
+ assignmentId,
532
+ ownerId,
533
+ isRejected: Boolean(isRejected),
534
+ backlog,
535
+ isPaused: Boolean(isPaused),
536
+ });
537
+ }
538
+ /**
539
+ * Shared eligibility/scoring evaluation used by explainMatch() and
540
+ * previewMatch(). Read-only: never claims, writes, or records decisions.
541
+ */
542
+ async evaluateCandidateForAssignment(user, assignment, tagsCsv, basePriority, modelWeights, opts) {
509
543
  const reasons = [];
510
544
  let eligible = true;
545
+ const assignmentId = opts.assignmentId ?? '';
546
+ const ownerId = opts.ownerId ?? null;
547
+ const isRejected = opts.isRejected ?? false;
548
+ const isPaused = opts.isPaused ?? false;
549
+ const backlog = opts.backlog ?? 0;
511
550
  if (assignment.vetoedUsers?.includes(user.id)) {
512
551
  reasons.push({ kind: 'assignmentVeto' });
513
552
  eligible = false;
514
553
  }
515
- const [isRejected, backlog, isPaused] = await Promise.all([
516
- this.redisClient.sIsMember(this.keys.userRejected(user.id), assignmentId),
517
- this.redisClient.sCard(this.keys.userAssignments(user.id)),
518
- this.redisClient.sIsMember(this.keys.pausedUsers(), user.id),
519
- ]);
520
554
  if (isRejected) {
521
555
  reasons.push({ kind: 'rejectedPreviously' });
522
556
  eligible = false;
@@ -575,7 +609,7 @@ class AssignmentMatcher {
575
609
  reasons.push(...explained.reasons);
576
610
  }
577
611
  else {
578
- [score, combinedPriority] = await this.matchScore(user, tagsCsv, basePriority, assignmentId, assignment.skillThresholds);
612
+ [score, combinedPriority] = await this.matchScore(user, tagsCsv, basePriority, assignmentId || undefined, assignment.skillThresholds);
579
613
  reasons.push({ kind: 'customScore', score });
580
614
  }
581
615
  if (!score)
@@ -598,6 +632,54 @@ class AssignmentMatcher {
598
632
  reasons,
599
633
  };
600
634
  }
635
+ /**
636
+ * Preview which users would be candidates for a hypothetical assignment
637
+ * without creating it or claiming anything. Uses the same scoring, hard
638
+ * rules, and learning re-ranking as real matching, so the ranked result
639
+ * matches what `explainMatch()` would report if the assignment were added.
640
+ */
641
+ async previewMatch(input, opts) {
642
+ await this.readyPromise;
643
+ const evaluatedAt = Date.now();
644
+ const assignment = {
645
+ id: '',
646
+ tags: input.tags,
647
+ priority: input.priority ?? 0,
648
+ skillThresholds: input.skillThresholds,
649
+ allowedCidrs: input.allowedCidrs,
650
+ vetoedUsers: input.vetoedUsers,
651
+ latitude: input.latitude,
652
+ longitude: input.longitude,
653
+ maxDistanceKm: input.maxDistanceKm,
654
+ requireGeo: input.requireGeo,
655
+ };
656
+ const tagsCsv = [...input.tags, ...(this.enableDefaultMatching ? ['default'] : [])].join(',');
657
+ const basePriority = Number(assignment.priority) || 0;
658
+ let userList;
659
+ if (opts?.userIds && opts.userIds.length > 0) {
660
+ const jsons = await this.redisClient.hmGet(this.usersKey, opts.userIds);
661
+ userList = jsons
662
+ .filter((json) => Boolean(json))
663
+ .map((json) => JSON.parse(json));
664
+ }
665
+ else {
666
+ const all = await this.redisClient.hGetAll(this.usersKey);
667
+ userList = Object.values(all).map((json) => JSON.parse(json));
668
+ }
669
+ const paused = new Set(await this.redisClient.sMembers(this.keys.pausedUsers()));
670
+ const modelWeights = this.enableLearning ? await this.learning.getModel() : undefined;
671
+ const candidates = await Promise.all(userList.map(async (user) => {
672
+ const backlog = await this.redisClient.sCard(this.keys.userAssignments(user.id));
673
+ return this.evaluateCandidateForAssignment(user, assignment, tagsCsv, basePriority, modelWeights, {
674
+ ownerId: null,
675
+ isRejected: false,
676
+ backlog,
677
+ isPaused: paused.has(user.id),
678
+ });
679
+ }));
680
+ (0, decision_trace_1.sortCandidates)(candidates);
681
+ return { tags: input.tags, priority: basePriority, evaluatedAt, candidates };
682
+ }
601
683
  /** Build and record this pass's decision traces; failures never break matching. */
602
684
  async recordPassTraces(collector, winners, workflowGrants, mode, users) {
603
685
  if (winners.size === 0 && workflowGrants.length === 0)
@@ -922,6 +1004,15 @@ class AssignmentMatcher {
922
1004
  const json = await this.redisClient.hGet(this.usersKey, userId);
923
1005
  return json ? JSON.parse(json) : null;
924
1006
  }
1007
+ /**
1008
+ * Whether a user is registered in the pool. Used by the workflow engine
1009
+ * (via the WorkflowHost interface) to validate an initiator before
1010
+ * starting a run that targets 'initiator'.
1011
+ */
1012
+ async userExists(userId) {
1013
+ await this.readyPromise;
1014
+ return Boolean(await this.redisClient.hExists(this.usersKey, userId));
1015
+ }
925
1016
  /** All stored users. The pool is small by design; for load metadata see getQueueStats(). */
926
1017
  async getUsers() {
927
1018
  await this.readyPromise;
@@ -967,6 +1058,19 @@ class AssignmentMatcher {
967
1058
  await this.touchUser(userId);
968
1059
  return wasPaused > 0;
969
1060
  }
1061
+ /**
1062
+ * Requeue every pending (matched but not yet accepted) assignment the user
1063
+ * holds so other users can pick them up — the operator's "this person is
1064
+ * gone, redistribute their work" move, typically paired with `pauseUser`
1065
+ * (which alone deliberately preserves the backlog). Accepted assignments
1066
+ * (work in progress) are never touched. Requeued assignments keep their
1067
+ * original wait clock, and a still-paused user won't win them back until
1068
+ * resumed. Returns the released assignment ids ([] when nothing was held).
1069
+ */
1070
+ async releaseUserAssignments(userId) {
1071
+ await this.readyPromise;
1072
+ return this.releaseUserPendingAssignments(userId);
1073
+ }
970
1074
  /** Whether a user is currently paused. */
971
1075
  async isUserPaused(userId) {
972
1076
  await this.readyPromise;
@@ -1570,6 +1674,17 @@ class AssignmentMatcher {
1570
1674
  }
1571
1675
  }
1572
1676
  await rm.exec();
1677
+ for (const s of selected) {
1678
+ if (!claimedIds.has(s.id))
1679
+ continue;
1680
+ this.emitAssignmentLifecycle({
1681
+ kind: 'pending',
1682
+ taskId: s.id,
1683
+ workerId: user.id,
1684
+ matchedAt: now,
1685
+ expiresAt: now + this.matchExpirationMs,
1686
+ });
1687
+ }
1573
1688
  }
1574
1689
  return claimedIds;
1575
1690
  }
@@ -1941,6 +2056,14 @@ class AssignmentMatcher {
1941
2056
  value: assignmentId,
1942
2057
  });
1943
2058
  await transfer.exec();
2059
+ const reassignedAt = Date.now();
2060
+ this.emitAssignmentLifecycle({
2061
+ kind: 'pending',
2062
+ taskId: assignmentId,
2063
+ workerId: userId,
2064
+ matchedAt: reassignedAt,
2065
+ expiresAt: reassignedAt + this.matchExpirationMs,
2066
+ });
1944
2067
  }
1945
2068
  await this.touchUser(userId);
1946
2069
  await this.recordManualAssignTrace(assignmentId, userId, force, previousOwnerId ?? null);
@@ -1997,6 +2120,12 @@ class AssignmentMatcher {
1997
2120
  if (this.enableLearning) {
1998
2121
  await this.learning.applyOutcome(assignmentId, 'accept');
1999
2122
  }
2123
+ this.emitAssignmentLifecycle({
2124
+ kind: 'accepted',
2125
+ taskId: assignmentId,
2126
+ workerId: userId,
2127
+ acceptedAt: Date.now(),
2128
+ });
2000
2129
  await this.touchUser(userId);
2001
2130
  return true;
2002
2131
  }
@@ -2017,6 +2146,12 @@ class AssignmentMatcher {
2017
2146
  if (this.enableLearning) {
2018
2147
  await this.learning.applyOutcome(assignmentId, 'reject');
2019
2148
  }
2149
+ this.emitAssignmentLifecycle({
2150
+ kind: 'rejected',
2151
+ taskId: assignmentId,
2152
+ workerId: userId,
2153
+ rejectedAt: Date.now(),
2154
+ });
2020
2155
  await this.touchUser(userId);
2021
2156
  if (json) {
2022
2157
  await this.addAssignment(JSON.parse(json));
@@ -2067,6 +2202,12 @@ class AssignmentMatcher {
2067
2202
  payload: result?.data,
2068
2203
  });
2069
2204
  }
2205
+ this.emitAssignmentLifecycle({
2206
+ kind: 'completed',
2207
+ taskId: assignmentId,
2208
+ workerId: userId,
2209
+ completedAt: now,
2210
+ });
2070
2211
  return true;
2071
2212
  }
2072
2213
  /**
@@ -2187,6 +2328,15 @@ class AssignmentMatcher {
2187
2328
  await this.readyPromise;
2188
2329
  return this.workflow.getActiveWorkflowsForUser(userId);
2189
2330
  }
2331
+ /**
2332
+ * List workflow instances (runs), newest-created first, optionally
2333
+ * filtered by status and/or workflow definition. Paginated via an opaque
2334
+ * cursor from the previous page's `nextCursor`.
2335
+ */
2336
+ async listWorkflowInstances(query) {
2337
+ await this.readyPromise;
2338
+ return this.workflow.listWorkflowInstances(query);
2339
+ }
2190
2340
  /**
2191
2341
  * Cancel a workflow instance.
2192
2342
  */
@@ -2194,6 +2344,16 @@ class AssignmentMatcher {
2194
2344
  await this.readyPromise;
2195
2345
  return this.workflow.cancelWorkflow(instanceId);
2196
2346
  }
2347
+ /**
2348
+ * Complete (or fail, via `outcome.success: false`) an external step from
2349
+ * outside this process — the counterpart to the `step.ready` transition
2350
+ * delivered via `onWorkflowEvent`. Throws if the step isn't the run's
2351
+ * current step (or a pending parallel branch) or isn't an external step.
2352
+ */
2353
+ async completeWorkflowStep(instanceId, stepId, outcome) {
2354
+ await this.readyPromise;
2355
+ return this.workflow.completeWorkflowStep(instanceId, stepId, outcome);
2356
+ }
2197
2357
  /**
2198
2358
  * Check and process expired workflow steps.
2199
2359
  * Should be called periodically.
@@ -2202,6 +2362,15 @@ class AssignmentMatcher {
2202
2362
  await this.readyPromise;
2203
2363
  return this.workflow.processExpiredWorkflowSteps();
2204
2364
  }
2365
+ /**
2366
+ * Non-blocking drain of up to `maxEvents` due workflow events. Intended
2367
+ * for hosts that sweep many matcher instances periodically rather than
2368
+ * running `startOrchestrator()`'s dedicated blocking loop per instance.
2369
+ */
2370
+ async processWorkflowEvents(maxEvents) {
2371
+ await this.readyPromise;
2372
+ return this.workflow.processWorkflowEvents(maxEvents);
2373
+ }
2205
2374
  /**
2206
2375
  * Publish a workflow event to the Redis Stream.
2207
2376
  */
@@ -2279,6 +2448,12 @@ class AssignmentMatcher {
2279
2448
  multi.zRem(this.pendingAssignmentsExpiryKey, id);
2280
2449
  multi.hDel(this.assignmentOwnerKey, id);
2281
2450
  await multi.exec();
2451
+ this.emitAssignmentLifecycle({
2452
+ kind: 'expired',
2453
+ taskId: id,
2454
+ workerId: owner ?? null,
2455
+ expiredAt: now,
2456
+ });
2282
2457
  if (this.enableLearning) {
2283
2458
  await this.learning.applyOutcome(id, 'expire');
2284
2459
  }
@@ -2355,7 +2530,7 @@ class AssignmentMatcher {
2355
2530
  const pendingCount = await this.redisClient.sCard(this.keys.userAssignments(userId));
2356
2531
  if (pendingCount === 0)
2357
2532
  continue;
2358
- await this.releaseUserPendingAssignments(userId);
2533
+ await this.releaseUserPendingAssignments(userId, 'idle');
2359
2534
  await this.removeUser(userId);
2360
2535
  removed.push(userId);
2361
2536
  }
@@ -2364,9 +2539,10 @@ class AssignmentMatcher {
2364
2539
  /**
2365
2540
  * Requeue all pending assignments currently held by a user.
2366
2541
  */
2367
- async releaseUserPendingAssignments(userId) {
2542
+ async releaseUserPendingAssignments(userId, reason = 'operator') {
2368
2543
  const members = await this.redisClient.sMembers(this.keys.userAssignments(userId));
2369
2544
  const now = Date.now();
2545
+ const released = [];
2370
2546
  for (const member of members) {
2371
2547
  const id = member.split(':')[1];
2372
2548
  const json = await this.redisClient.hGet(this.pendingAssignmentsKey, id);
@@ -2376,6 +2552,13 @@ class AssignmentMatcher {
2376
2552
  multi.zRem(this.pendingAssignmentsExpiryKey, id);
2377
2553
  multi.hDel(this.assignmentOwnerKey, id);
2378
2554
  await multi.exec();
2555
+ this.emitAssignmentLifecycle({
2556
+ kind: 'released',
2557
+ taskId: id,
2558
+ workerId: userId,
2559
+ reason,
2560
+ releasedAt: now,
2561
+ });
2379
2562
  if (this.enableLearning) {
2380
2563
  await this.learning.applyOutcome(id, 'expire');
2381
2564
  }
@@ -2391,7 +2574,9 @@ class AssignmentMatcher {
2391
2574
  if (json) {
2392
2575
  await this.addAssignment(JSON.parse(json));
2393
2576
  }
2577
+ released.push(id);
2394
2578
  }
2579
+ return released;
2395
2580
  }
2396
2581
  startIdleUserInterval(intervalMs = 10000) {
2397
2582
  if (this.idleUserInterval)