@atolis-hq/wake 0.4.95 → 0.4.97
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/src/activities/agent/agent-activity.js +12 -1
- package/dist/src/activities/agent/agent-result.d.ts +1 -0
- package/dist/src/activities/agent/agent-result.js +1 -0
- package/dist/src/activities/contracts/activity.d.ts +7 -0
- package/dist/src/artifacts/application/delegation-artifacts.d.ts +29 -0
- package/dist/src/artifacts/application/delegation-artifacts.js +37 -0
- package/dist/src/artifacts/index.d.ts +1 -0
- package/dist/src/artifacts/index.js +1 -0
- package/dist/src/bootstrap/composition-root.d.ts +6 -1
- package/dist/src/bootstrap/composition-root.js +50 -12
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +3 -1
- package/dist/src/control-plane/application/activation-scheduler.js +28 -43
- package/dist/src/control-plane/application/advance-once-dispatch.d.ts +1 -14
- package/dist/src/control-plane/application/advance-once-dispatch.js +14 -26
- package/dist/src/control-plane/application/dispatch-resources.d.ts +4 -0
- package/dist/src/control-plane/application/dispatch-resources.js +13 -0
- package/dist/src/control-plane/application/in-process-scheduler-serialiser.d.ts +1 -0
- package/dist/src/control-plane/application/in-process-scheduler-serialiser.js +15 -0
- package/dist/src/control-plane/application/runner-quota-outcome.d.ts +13 -0
- package/dist/src/control-plane/application/runner-quota-outcome.js +23 -0
- package/dist/src/execution/application/execution-service.js +27 -5
- package/dist/src/execution/application/execution-validation.d.ts +6 -1
- package/dist/src/execution/application/execution-validation.js +29 -11
- package/dist/src/execution/application/repository-assignments.d.ts +11 -0
- package/dist/src/execution/application/repository-assignments.js +18 -0
- package/dist/src/execution/application/run-lifecycle.d.ts +1 -0
- package/dist/src/execution/application/run-lifecycle.js +30 -10
- package/dist/src/execution/contracts/commands.d.ts +2 -0
- package/dist/src/execution/contracts/events.d.ts +20 -0
- package/dist/src/execution/contracts/events.js +9 -0
- package/dist/src/execution/contracts/repository-assignment.d.ts +17 -0
- package/dist/src/execution/contracts/repository-assignment.js +9 -0
- package/dist/src/execution/contracts/views.d.ts +5 -0
- package/dist/src/execution/contracts/workspace.d.ts +6 -0
- package/dist/src/execution/domain/run.js +9 -0
- package/dist/src/execution/index.d.ts +3 -0
- package/dist/src/execution/index.js +3 -0
- package/dist/src/execution/infrastructure/workspace/git-source.d.ts +6 -0
- package/dist/src/execution/infrastructure/workspace/git-source.js +35 -0
- package/dist/src/execution/infrastructure/workspace/git-workspace.d.ts +5 -0
- package/dist/src/execution/infrastructure/workspace/git-workspace.js +50 -3
- package/dist/src/integrations/application/artifact-registration-reactor.d.ts +6 -0
- package/dist/src/integrations/application/artifact-registration-reactor.js +35 -11
- package/dist/src/integrations/application/artifact-source.d.ts +9 -0
- package/dist/src/integrations/application/artifact-source.js +12 -0
- package/dist/src/integrations/application/delegation-outputs.d.ts +15 -0
- package/dist/src/integrations/application/delegation-outputs.js +118 -0
- package/dist/src/integrations/contracts/provider.d.ts +3 -0
- package/dist/src/integrations/fake/external-source.d.ts +1 -0
- package/dist/src/integrations/fake/inbound-translator.js +1 -0
- package/dist/src/integrations/fake/provider.d.ts +1 -0
- package/dist/src/integrations/fake/provider.js +11 -2
- package/dist/src/integrations/github/provider.js +7 -1
- package/dist/src/integrations/index.d.ts +1 -0
- package/dist/src/integrations/index.js +1 -0
- package/dist/src/orchestration/application/accept-signal.d.ts +3 -1
- package/dist/src/orchestration/application/accept-signal.js +2 -0
- package/dist/src/orchestration/application/advance-workflow.d.ts +0 -1
- package/dist/src/orchestration/application/advance-workflow.js +0 -4
- package/dist/src/orchestration/application/deferred-signals.d.ts +21 -0
- package/dist/src/orchestration/application/deferred-signals.js +119 -0
- package/dist/src/orchestration/application/delegated-work.d.ts +60 -0
- package/dist/src/orchestration/application/delegated-work.js +456 -0
- package/dist/src/orchestration/application/delegation-gate.d.ts +17 -0
- package/dist/src/orchestration/application/delegation-gate.js +31 -0
- package/dist/src/orchestration/application/delegation-ledger.d.ts +28 -0
- package/dist/src/orchestration/application/delegation-ledger.js +79 -0
- package/dist/src/orchestration/application/delegation-reservation.d.ts +15 -0
- package/dist/src/orchestration/application/delegation-reservation.js +77 -0
- package/dist/src/orchestration/application/expire-timed-out-waits.d.ts +1 -1
- package/dist/src/orchestration/application/expire-timed-out-waits.js +2 -2
- package/dist/src/orchestration/application/orchestration-projection.js +5 -1
- package/dist/src/orchestration/application/orchestration-repository.d.ts +5 -0
- package/dist/src/orchestration/application/orchestration-repository.js +69 -11
- package/dist/src/orchestration/application/orchestration-service.d.ts +43 -3
- package/dist/src/orchestration/application/orchestration-service.js +73 -20
- package/dist/src/orchestration/application/resource-transition-matching.js +11 -6
- package/dist/src/orchestration/application/start-workflow.js +4 -2
- package/dist/src/orchestration/application/workflow-definition-registry.d.ts +5 -1
- package/dist/src/orchestration/application/workflow-definition-registry.js +16 -3
- package/dist/src/orchestration/contracts/commands.d.ts +1 -0
- package/dist/src/orchestration/contracts/delegation-ports.d.ts +19 -0
- package/dist/src/orchestration/contracts/delegation-ports.js +1 -0
- package/dist/src/orchestration/contracts/delegation.d.ts +143 -0
- package/dist/src/orchestration/contracts/delegation.js +115 -0
- package/dist/src/orchestration/contracts/event-decoder.js +19 -0
- package/dist/src/orchestration/contracts/event-factory.js +16 -0
- package/dist/src/orchestration/contracts/events.d.ts +39 -0
- package/dist/src/orchestration/contracts/events.js +8 -0
- package/dist/src/orchestration/contracts/views.d.ts +8 -0
- package/dist/src/orchestration/contracts/vocabulary.d.ts +3 -0
- package/dist/src/orchestration/contracts/vocabulary.js +1 -0
- package/dist/src/orchestration/domain/workflow-completion.d.ts +3 -0
- package/dist/src/orchestration/domain/workflow-completion.js +9 -0
- package/dist/src/orchestration/domain/workflow-instance-events.d.ts +2 -0
- package/dist/src/orchestration/domain/workflow-instance-events.js +37 -0
- package/dist/src/orchestration/index.d.ts +2 -0
- package/dist/src/orchestration/index.js +1 -0
- package/dist/src/work/application/work-projection.js +3 -0
- package/dist/src/work/application/work-service.js +16 -0
- package/dist/src/work/contracts/commands.d.ts +6 -0
- package/dist/src/work/contracts/events.d.ts +2 -1
- package/dist/src/work/contracts/events.js +8 -0
- package/dist/src/work/contracts/views.d.ts +2 -1
- package/dist/src/work/domain/work-item.js +3 -0
- package/package.json +1 -1
|
@@ -28,5 +28,9 @@ export declare class WorkflowDefinitionRegistry {
|
|
|
28
28
|
readonly commandId: string;
|
|
29
29
|
}): Promise<void>;
|
|
30
30
|
private isRegistered;
|
|
31
|
-
resolve(view: Pick<WorkflowInstanceView, 'workflowName' | 'workflowDefinitionFingerprint'
|
|
31
|
+
resolve(view: Pick<WorkflowInstanceView, 'workflowName' | 'workflowDefinitionFingerprint'>, options?: {
|
|
32
|
+
readonly journalFallback?: boolean;
|
|
33
|
+
}): Promise<CompiledWorkflow>;
|
|
34
|
+
/** Committed delegation recovery cannot depend on projection catch-up or current configuration. */
|
|
35
|
+
private fromJournal;
|
|
32
36
|
}
|
|
@@ -101,7 +101,7 @@ export class WorkflowDefinitionRegistry {
|
|
|
101
101
|
this.knownRegistered.add(key);
|
|
102
102
|
return found;
|
|
103
103
|
}
|
|
104
|
-
async resolve(view) {
|
|
104
|
+
async resolve(view, options = {}) {
|
|
105
105
|
if (view.workflowDefinitionFingerprint === undefined)
|
|
106
106
|
return this.currentDefinition(view.workflowName).definition;
|
|
107
107
|
const current = this.current[view.workflowName];
|
|
@@ -109,8 +109,21 @@ export class WorkflowDefinitionRegistry {
|
|
|
109
109
|
workflowDefinitionFingerprint(current) === view.workflowDefinitionFingerprint)
|
|
110
110
|
return current;
|
|
111
111
|
const stored = await this.projections?.read(workflowDefinitionsProjection.name, workflowDefinitionKey(view.workflowName, view.workflowDefinitionFingerprint));
|
|
112
|
-
if (stored
|
|
112
|
+
if (stored !== null && stored !== undefined)
|
|
113
|
+
return stored.value;
|
|
114
|
+
if (options.journalFallback !== true)
|
|
113
115
|
throw new WorkflowDefinitionUnavailableError();
|
|
114
|
-
return
|
|
116
|
+
return this.fromJournal(view.workflowName, view.workflowDefinitionFingerprint);
|
|
117
|
+
}
|
|
118
|
+
/** Committed delegation recovery cannot depend on projection catch-up or current configuration. */
|
|
119
|
+
async fromJournal(name, fingerprint) {
|
|
120
|
+
for (const event of await this.journal.readStream(workflowDefinitionsStream())) {
|
|
121
|
+
const owned = selectOrchestrationEvent(event);
|
|
122
|
+
if (owned?.event.eventType === OrchestrationEventType.WorkflowDefinitionRegistered &&
|
|
123
|
+
owned.event.payload.workflowName === name &&
|
|
124
|
+
owned.event.payload.fingerprint === fingerprint)
|
|
125
|
+
return owned.event.payload.compiledDefinition;
|
|
126
|
+
}
|
|
127
|
+
throw new WorkflowDefinitionUnavailableError();
|
|
115
128
|
}
|
|
116
129
|
}
|
|
@@ -5,6 +5,7 @@ interface StartWorkflowBase {
|
|
|
5
5
|
readonly workflowInstanceId: WorkflowInstanceId;
|
|
6
6
|
readonly workItemId: WorkItemId;
|
|
7
7
|
readonly workflowName: WorkflowName;
|
|
8
|
+
readonly workflowDefinitionFingerprint?: string;
|
|
8
9
|
readonly orchestrationGroupId: OrchestrationGroupId;
|
|
9
10
|
}
|
|
10
11
|
type PrimaryWorkflowStart = {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CommandContext } from '@atolis-hq/eventing';
|
|
2
|
+
import type { RepositoryAssignment } from '../../execution/index.js';
|
|
3
|
+
import type { DelegatedAssignment, DelegationReservation, DelegationResult, DelegationRevisionReference, RepositoryAssignmentRequest } from './delegation.js';
|
|
4
|
+
import type { WorkflowInstanceView } from './views.js';
|
|
5
|
+
/** Trusted Bootstrap adapters; no provider, Run or session authority is supplied by assignments. */
|
|
6
|
+
export interface DelegationArtifacts {
|
|
7
|
+
validateInputs(parent: WorkflowInstanceView, references: readonly DelegationRevisionReference[]): Promise<void>;
|
|
8
|
+
registerChild(grant: {
|
|
9
|
+
readonly delegationId: string;
|
|
10
|
+
readonly parentWorkItemId: DelegationReservation['parentWorkItemId'];
|
|
11
|
+
readonly childWorkItemId: DelegationReservation['parentWorkItemId'];
|
|
12
|
+
readonly childReferences: readonly DelegationRevisionReference[];
|
|
13
|
+
}, context: CommandContext): Promise<void>;
|
|
14
|
+
qualifyingOutputs(child: WorkflowInstanceView, outputs: DelegatedAssignment['outputs']): Promise<DelegationResult['outputs'] | null>;
|
|
15
|
+
}
|
|
16
|
+
/** Resolves only repositories already authorized by the parent's resource scope. */
|
|
17
|
+
export interface DelegationRepositories {
|
|
18
|
+
resolve(parent: WorkflowInstanceView, request: RepositoryAssignmentRequest): Promise<RepositoryAssignment>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { activationId } from '../../activities/index.js';
|
|
3
|
+
import { workflowInstanceId } from './identifiers.js';
|
|
4
|
+
export declare const delegationRevisionReferenceSchema: z.ZodObject<{
|
|
5
|
+
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
6
|
+
revisionId: z.ZodString;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export type DelegationRevisionReference = z.infer<typeof delegationRevisionReferenceSchema>;
|
|
9
|
+
export declare const repositoryAssignmentRequestSchema: z.ZodObject<{
|
|
10
|
+
resourceId: z.ZodString;
|
|
11
|
+
sourceRef: z.ZodString;
|
|
12
|
+
sourceRevision: z.ZodOptional<z.ZodString>;
|
|
13
|
+
pullRequestBase: z.ZodString;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export type RepositoryAssignmentRequest = z.infer<typeof repositoryAssignmentRequestSchema>;
|
|
16
|
+
export declare const delegatedAssignmentSchema: z.ZodObject<{
|
|
17
|
+
assignmentId: z.ZodString;
|
|
18
|
+
objective: z.ZodString;
|
|
19
|
+
criteria: z.ZodArray<z.ZodString>;
|
|
20
|
+
workflowName: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").WorkflowName, string>>;
|
|
21
|
+
workflowFingerprint: z.ZodString;
|
|
22
|
+
context: z.ZodArray<z.ZodObject<{
|
|
23
|
+
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
24
|
+
revisionId: z.ZodString;
|
|
25
|
+
}, z.core.$strict>>;
|
|
26
|
+
repository: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
resourceId: z.ZodString;
|
|
28
|
+
sourceRef: z.ZodString;
|
|
29
|
+
sourceRevision: z.ZodOptional<z.ZodString>;
|
|
30
|
+
pullRequestBase: z.ZodString;
|
|
31
|
+
}, z.core.$strict>>;
|
|
32
|
+
outputs: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
path: z.ZodString;
|
|
35
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
36
|
+
name: z.ZodString;
|
|
37
|
+
kind: z.ZodLiteral<"change">;
|
|
38
|
+
requireReview: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
+
requireChecks: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
}, z.core.$strict>]>>;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
export type DelegatedAssignment = z.infer<typeof delegatedAssignmentSchema>;
|
|
43
|
+
export declare const delegationReservationSchema: z.ZodObject<{
|
|
44
|
+
cohortId: z.ZodString;
|
|
45
|
+
parentWorkflowInstanceId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").WorkflowInstanceId, string>>;
|
|
46
|
+
parentWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
47
|
+
rootWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
48
|
+
activationId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../activities/index.js").ActivationId, string>>;
|
|
49
|
+
runId: z.ZodString;
|
|
50
|
+
ancestors: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>>;
|
|
51
|
+
maxDepth: z.ZodNumber;
|
|
52
|
+
maxDescendants: z.ZodNumber;
|
|
53
|
+
children: z.ZodArray<z.ZodObject<{
|
|
54
|
+
assignmentId: z.ZodString;
|
|
55
|
+
objective: z.ZodString;
|
|
56
|
+
criteria: z.ZodArray<z.ZodString>;
|
|
57
|
+
workflowName: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").WorkflowName, string>>;
|
|
58
|
+
workflowFingerprint: z.ZodString;
|
|
59
|
+
context: z.ZodArray<z.ZodObject<{
|
|
60
|
+
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
61
|
+
revisionId: z.ZodString;
|
|
62
|
+
}, z.core.$strict>>;
|
|
63
|
+
outputs: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
64
|
+
name: z.ZodString;
|
|
65
|
+
path: z.ZodString;
|
|
66
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
kind: z.ZodLiteral<"change">;
|
|
69
|
+
requireReview: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
requireChecks: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
}, z.core.$strict>]>>;
|
|
72
|
+
repository: z.ZodOptional<z.ZodObject<{
|
|
73
|
+
resourceId: z.ZodString;
|
|
74
|
+
sourceRef: z.ZodString;
|
|
75
|
+
pullRequestBase: z.ZodString;
|
|
76
|
+
sourceRevision: z.ZodString;
|
|
77
|
+
}, z.core.$strict>>;
|
|
78
|
+
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
79
|
+
workflowInstanceId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").WorkflowInstanceId, string>>;
|
|
80
|
+
grantId: z.ZodString;
|
|
81
|
+
}, z.core.$strict>>;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
export type DelegationReservation = z.infer<typeof delegationReservationSchema>;
|
|
84
|
+
export declare const delegationResultSchema: z.ZodObject<{
|
|
85
|
+
cohortId: z.ZodString;
|
|
86
|
+
childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
87
|
+
outputs: z.ZodArray<z.ZodObject<{
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
reference: z.ZodUnion<readonly [z.ZodObject<{
|
|
90
|
+
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
91
|
+
revisionId: z.ZodString;
|
|
92
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
93
|
+
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
94
|
+
resourceId: z.ZodString;
|
|
95
|
+
repositoryResourceId: z.ZodString;
|
|
96
|
+
revision: z.ZodString;
|
|
97
|
+
branch: z.ZodString;
|
|
98
|
+
pullRequestBase: z.ZodString;
|
|
99
|
+
runId: z.ZodString;
|
|
100
|
+
}, z.core.$strict>]>;
|
|
101
|
+
}, z.core.$strict>>;
|
|
102
|
+
}, z.core.$strict>;
|
|
103
|
+
export type DelegationResult = z.infer<typeof delegationResultSchema>;
|
|
104
|
+
export declare const delegationWaitSchema: z.ZodObject<{
|
|
105
|
+
cohortId: z.ZodString;
|
|
106
|
+
activationId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../activities/index.js").ActivationId, string>>;
|
|
107
|
+
}, z.core.$strict>;
|
|
108
|
+
export declare const delegationJoinSchema: z.ZodObject<{
|
|
109
|
+
cohortId: z.ZodString;
|
|
110
|
+
results: z.ZodArray<z.ZodObject<{
|
|
111
|
+
cohortId: z.ZodString;
|
|
112
|
+
childWorkItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
113
|
+
outputs: z.ZodArray<z.ZodObject<{
|
|
114
|
+
name: z.ZodString;
|
|
115
|
+
reference: z.ZodUnion<readonly [z.ZodObject<{
|
|
116
|
+
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
117
|
+
revisionId: z.ZodString;
|
|
118
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
119
|
+
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
120
|
+
resourceId: z.ZodString;
|
|
121
|
+
repositoryResourceId: z.ZodString;
|
|
122
|
+
revision: z.ZodString;
|
|
123
|
+
branch: z.ZodString;
|
|
124
|
+
pullRequestBase: z.ZodString;
|
|
125
|
+
runId: z.ZodString;
|
|
126
|
+
}, z.core.$strict>]>;
|
|
127
|
+
}, z.core.$strict>>;
|
|
128
|
+
}, z.core.$strict>>;
|
|
129
|
+
}, z.core.$strict>;
|
|
130
|
+
export interface DelegationLimits {
|
|
131
|
+
readonly maxDepth: number;
|
|
132
|
+
readonly maxDescendants: number;
|
|
133
|
+
}
|
|
134
|
+
/** Obtained from the active Run capability, never from an assignment payload. */
|
|
135
|
+
export interface DelegationCaller {
|
|
136
|
+
readonly workflowInstanceId: ReturnType<typeof workflowInstanceId>;
|
|
137
|
+
readonly activationId: ReturnType<typeof activationId>;
|
|
138
|
+
readonly runId: string;
|
|
139
|
+
}
|
|
140
|
+
/** Retryable rejection: callers retain their signal or execution evidence until the cohort settles. */
|
|
141
|
+
export declare class DelegationPendingError extends Error {
|
|
142
|
+
constructor(id: string);
|
|
143
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { activationId } from '../../activities/index.js';
|
|
3
|
+
import { brandedStringSchema } from '../../kernel/index.js';
|
|
4
|
+
import { workItemId } from '../../work/index.js';
|
|
5
|
+
import { workflowInstanceId, workflowName } from './identifiers.js';
|
|
6
|
+
import { DelegationOutputKind } from './vocabulary.js';
|
|
7
|
+
export const delegationRevisionReferenceSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
workItemId: brandedStringSchema(workItemId),
|
|
10
|
+
revisionId: z.string().min(1),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
export const repositoryAssignmentRequestSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
resourceId: z.string().min(1),
|
|
16
|
+
sourceRef: z.string().trim().min(1),
|
|
17
|
+
sourceRevision: z
|
|
18
|
+
.string()
|
|
19
|
+
.regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i)
|
|
20
|
+
.optional(),
|
|
21
|
+
pullRequestBase: z.string().trim().min(1),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
export const delegatedAssignmentSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
assignmentId: z.string().min(1),
|
|
27
|
+
objective: z.string().trim().min(1),
|
|
28
|
+
criteria: z.array(z.string().trim().min(1)).min(1),
|
|
29
|
+
workflowName: brandedStringSchema(workflowName),
|
|
30
|
+
workflowFingerprint: z.string().min(1),
|
|
31
|
+
context: z.array(delegationRevisionReferenceSchema),
|
|
32
|
+
repository: repositoryAssignmentRequestSchema.optional(),
|
|
33
|
+
outputs: z
|
|
34
|
+
.array(z.union([
|
|
35
|
+
z.object({ name: z.string().min(1), path: z.string().min(1) }).strict(),
|
|
36
|
+
z
|
|
37
|
+
.object({
|
|
38
|
+
name: z.string().min(1),
|
|
39
|
+
kind: z.literal(DelegationOutputKind.Change),
|
|
40
|
+
requireReview: z.boolean().optional(),
|
|
41
|
+
requireChecks: z.boolean().optional(),
|
|
42
|
+
})
|
|
43
|
+
.strict(),
|
|
44
|
+
]))
|
|
45
|
+
.min(1),
|
|
46
|
+
})
|
|
47
|
+
.strict();
|
|
48
|
+
export const delegationReservationSchema = z
|
|
49
|
+
.object({
|
|
50
|
+
cohortId: z.string().min(1),
|
|
51
|
+
parentWorkflowInstanceId: brandedStringSchema(workflowInstanceId),
|
|
52
|
+
parentWorkItemId: brandedStringSchema(workItemId),
|
|
53
|
+
rootWorkItemId: brandedStringSchema(workItemId),
|
|
54
|
+
activationId: brandedStringSchema(activationId),
|
|
55
|
+
runId: z.string().min(1),
|
|
56
|
+
ancestors: z.array(brandedStringSchema(workItemId)),
|
|
57
|
+
maxDepth: z.number().int().positive(),
|
|
58
|
+
maxDescendants: z.number().int().positive(),
|
|
59
|
+
children: z
|
|
60
|
+
.array(delegatedAssignmentSchema
|
|
61
|
+
.extend({
|
|
62
|
+
repository: repositoryAssignmentRequestSchema
|
|
63
|
+
.extend({
|
|
64
|
+
sourceRevision: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i),
|
|
65
|
+
})
|
|
66
|
+
.strict()
|
|
67
|
+
.optional(),
|
|
68
|
+
workItemId: brandedStringSchema(workItemId),
|
|
69
|
+
workflowInstanceId: brandedStringSchema(workflowInstanceId),
|
|
70
|
+
grantId: z.string().min(1),
|
|
71
|
+
})
|
|
72
|
+
.strict())
|
|
73
|
+
.min(1),
|
|
74
|
+
})
|
|
75
|
+
.strict();
|
|
76
|
+
export const delegationResultSchema = z
|
|
77
|
+
.object({
|
|
78
|
+
cohortId: z.string().min(1),
|
|
79
|
+
childWorkItemId: brandedStringSchema(workItemId),
|
|
80
|
+
outputs: z
|
|
81
|
+
.array(z
|
|
82
|
+
.object({
|
|
83
|
+
name: z.string().min(1),
|
|
84
|
+
reference: z.union([
|
|
85
|
+
delegationRevisionReferenceSchema,
|
|
86
|
+
z
|
|
87
|
+
.object({
|
|
88
|
+
workItemId: brandedStringSchema(workItemId),
|
|
89
|
+
resourceId: z.string().min(1),
|
|
90
|
+
repositoryResourceId: z.string().min(1),
|
|
91
|
+
revision: z.string().min(1),
|
|
92
|
+
branch: z.string().min(1),
|
|
93
|
+
pullRequestBase: z.string().min(1),
|
|
94
|
+
runId: z.string().min(1),
|
|
95
|
+
})
|
|
96
|
+
.strict(),
|
|
97
|
+
]),
|
|
98
|
+
})
|
|
99
|
+
.strict())
|
|
100
|
+
.min(1),
|
|
101
|
+
})
|
|
102
|
+
.strict();
|
|
103
|
+
export const delegationWaitSchema = z
|
|
104
|
+
.object({ cohortId: z.string().min(1), activationId: brandedStringSchema(activationId) })
|
|
105
|
+
.strict();
|
|
106
|
+
export const delegationJoinSchema = z
|
|
107
|
+
.object({ cohortId: z.string().min(1), results: z.array(delegationResultSchema).min(1) })
|
|
108
|
+
.strict();
|
|
109
|
+
/** Retryable rejection: callers retain their signal or execution evidence until the cohort settles. */
|
|
110
|
+
export class DelegationPendingError extends Error {
|
|
111
|
+
constructor(id) {
|
|
112
|
+
super(`Workflow ${id} has an outstanding delegation; retry after it settles`);
|
|
113
|
+
this.name = 'DelegationPendingError';
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
1
2
|
import { z } from 'zod';
|
|
3
|
+
import { delegationJoinSchema, delegationReservationSchema, delegationResultSchema, delegationWaitSchema, } from './delegation.js';
|
|
2
4
|
import { eventDataSchema, eventEnvelopeSchema } from '@atolis-hq/eventing';
|
|
3
5
|
import { activationId, ActivityEventType, activityName, ActivityOutcomeKind, PullRequestCheckState, PullRequestMergeability, PullRequestState, } from '../../activities/index.js';
|
|
4
6
|
import { WorkspaceMode } from '../../execution/index.js';
|
|
@@ -214,6 +216,13 @@ const groupBudgetGrantedEnvelope = childGroupEnvelope(OrchestrationEventType.Gro
|
|
|
214
216
|
});
|
|
215
217
|
});
|
|
216
218
|
const eventSchemas = {
|
|
219
|
+
[OrchestrationEventType.DelegationFailed]: workflowEnvelope(OrchestrationEventType.DelegationFailed, z.object({ cohortId: z.string().min(1), reason: z.string().min(1) }).strict()),
|
|
220
|
+
[OrchestrationEventType.DelegationReconciliationFailed]: workflowEnvelope(OrchestrationEventType.DelegationReconciliationFailed, z.object({ cohortId: z.string().min(1), reason: z.string().min(1) }).strict()),
|
|
221
|
+
[OrchestrationEventType.DelegationReserved]: workflowEnvelope(OrchestrationEventType.DelegationReserved, delegationReservationSchema),
|
|
222
|
+
[OrchestrationEventType.DelegationRegistered]: workflowEnvelope(OrchestrationEventType.DelegationRegistered, z.object({ cohortId: z.string().min(1) }).strict()),
|
|
223
|
+
[OrchestrationEventType.DelegationResultSelected]: workflowEnvelope(OrchestrationEventType.DelegationResultSelected, delegationResultSchema),
|
|
224
|
+
[OrchestrationEventType.DelegationWaitStarted]: workflowEnvelope(OrchestrationEventType.DelegationWaitStarted, delegationWaitSchema),
|
|
225
|
+
[OrchestrationEventType.DelegationJoined]: workflowEnvelope(OrchestrationEventType.DelegationJoined, delegationJoinSchema),
|
|
217
226
|
[OrchestrationEventType.InstanceStarted]: workflowEnvelope(OrchestrationEventType.InstanceStarted, z.union([
|
|
218
227
|
z
|
|
219
228
|
.object({
|
|
@@ -278,6 +287,16 @@ const eventSchemas = {
|
|
|
278
287
|
})
|
|
279
288
|
.strict()),
|
|
280
289
|
[OrchestrationEventType.SignalWaitStarted]: workflowEnvelope(OrchestrationEventType.SignalWaitStarted, expectationSchema),
|
|
290
|
+
[OrchestrationEventType.SignalDeferred]: workflowEnvelope(OrchestrationEventType.SignalDeferred, z
|
|
291
|
+
.object({
|
|
292
|
+
stage: brandedStringSchema(stageName),
|
|
293
|
+
intentEventId: z.string().optional(),
|
|
294
|
+
resourceId: z.string().optional(),
|
|
295
|
+
revision: z.string().optional(),
|
|
296
|
+
signal: signalSchema,
|
|
297
|
+
target: transitionTargetSchema.optional(),
|
|
298
|
+
})
|
|
299
|
+
.strict()),
|
|
281
300
|
[OrchestrationEventType.SignalAccepted]: workflowEnvelope(OrchestrationEventType.SignalAccepted, signalSchema),
|
|
282
301
|
[OrchestrationEventType.SupplementalActivityQueued]: workflowEnvelope(OrchestrationEventType.SupplementalActivityQueued, z
|
|
283
302
|
.object({
|
|
@@ -4,6 +4,20 @@ import { OrchestrationEventType, } from './events.js';
|
|
|
4
4
|
// eslint-disable-next-line complexity
|
|
5
5
|
export function createOrchestrationEventData(input) {
|
|
6
6
|
switch (input.eventType) {
|
|
7
|
+
case OrchestrationEventType.DelegationFailed:
|
|
8
|
+
return createEventData(input);
|
|
9
|
+
case OrchestrationEventType.DelegationReconciliationFailed:
|
|
10
|
+
return createEventData(input);
|
|
11
|
+
case OrchestrationEventType.DelegationReserved:
|
|
12
|
+
return createEventData(input);
|
|
13
|
+
case OrchestrationEventType.DelegationRegistered:
|
|
14
|
+
return createEventData(input);
|
|
15
|
+
case OrchestrationEventType.DelegationResultSelected:
|
|
16
|
+
return createEventData(input);
|
|
17
|
+
case OrchestrationEventType.DelegationWaitStarted:
|
|
18
|
+
return createEventData(input);
|
|
19
|
+
case OrchestrationEventType.DelegationJoined:
|
|
20
|
+
return createEventData(input);
|
|
7
21
|
case OrchestrationEventType.WorkflowDefinitionRegistered:
|
|
8
22
|
return createEventData(input);
|
|
9
23
|
case OrchestrationEventType.InstanceStarted:
|
|
@@ -24,6 +38,8 @@ export function createOrchestrationEventData(input) {
|
|
|
24
38
|
return createEventData(input);
|
|
25
39
|
case OrchestrationEventType.SignalWaitStarted:
|
|
26
40
|
return createEventData(input);
|
|
41
|
+
case OrchestrationEventType.SignalDeferred:
|
|
42
|
+
return createEventData(input);
|
|
27
43
|
case OrchestrationEventType.SignalAccepted:
|
|
28
44
|
return createEventData(input);
|
|
29
45
|
case OrchestrationEventType.SupplementalActivityQueued:
|
|
@@ -3,9 +3,17 @@ import type { ActivationId, ActivityName, ActivityOutcome, ActivityOutcomeKind }
|
|
|
3
3
|
import type { WorkItemId } from '../../work/index.js';
|
|
4
4
|
import type { OrchestrationWaitingActivityOutcome } from './activity-outcome.js';
|
|
5
5
|
import type { ApprovalAuthority, CompiledResourceTransition, CompiledWorkflow, StageConfig, TransitionTarget } from './config.js';
|
|
6
|
+
import type { DelegationReservation, DelegationResult } from './delegation.js';
|
|
6
7
|
import type { CommandName, OrchestrationGroupId, SignalName, StageName, WorkflowInstanceId, WorkflowName } from './identifiers.js';
|
|
7
8
|
import type { ChildOrchestrationGroupStreamId, ChildOrchestrationGroupStreamRef, PrimaryOrchestrationGroupStreamRef, WorkflowDefinitionsStreamRef, WorkflowInstanceStreamRef } from './streams.js';
|
|
8
9
|
export declare const OrchestrationEventType: {
|
|
10
|
+
readonly DelegationReserved: "orchestration.delegation-reserved";
|
|
11
|
+
readonly DelegationRegistered: "orchestration.delegation-registered";
|
|
12
|
+
readonly DelegationResultSelected: "orchestration.delegation-result-selected";
|
|
13
|
+
readonly DelegationWaitStarted: "orchestration.delegation-wait-started";
|
|
14
|
+
readonly DelegationJoined: "orchestration.delegation-joined";
|
|
15
|
+
readonly DelegationFailed: "orchestration.delegation-failed";
|
|
16
|
+
readonly DelegationReconciliationFailed: "orchestration.delegation-reconciliation-failed";
|
|
9
17
|
readonly WorkflowDefinitionRegistered: "orchestration.workflow-definition-registered";
|
|
10
18
|
readonly InstanceStarted: "orchestration.instance-started";
|
|
11
19
|
readonly StageEntered: "orchestration.stage-entered";
|
|
@@ -17,6 +25,7 @@ export declare const OrchestrationEventType: {
|
|
|
17
25
|
readonly ActivityWaiting: "orchestration.activity-waiting";
|
|
18
26
|
readonly SignalWaitStarted: "orchestration.signal-wait-started";
|
|
19
27
|
readonly SignalAccepted: "orchestration.signal-accepted";
|
|
28
|
+
readonly SignalDeferred: "orchestration.signal-deferred";
|
|
20
29
|
readonly SupplementalActivityQueued: "orchestration.supplemental-activity-queued";
|
|
21
30
|
readonly SupplementalActivityDequeued: "orchestration.supplemental-activity-dequeued";
|
|
22
31
|
readonly RepeatCounted: "orchestration.repeat-counted";
|
|
@@ -35,7 +44,37 @@ export declare const OrchestrationEventType: {
|
|
|
35
44
|
readonly GroupClaimed: "orchestration.group-claimed";
|
|
36
45
|
readonly GroupBudgetGranted: "orchestration.group-budget-granted";
|
|
37
46
|
};
|
|
47
|
+
export interface DeferredWorkflowSignal {
|
|
48
|
+
readonly stage: StageName;
|
|
49
|
+
readonly intentEventId?: string;
|
|
50
|
+
readonly resourceId?: string;
|
|
51
|
+
readonly revision?: string;
|
|
52
|
+
readonly signal: OrchestrationSignal;
|
|
53
|
+
readonly target?: TransitionTarget;
|
|
54
|
+
}
|
|
38
55
|
export interface OrchestrationEventPayloads {
|
|
56
|
+
readonly [OrchestrationEventType.SignalDeferred]: DeferredWorkflowSignal;
|
|
57
|
+
readonly [OrchestrationEventType.DelegationFailed]: {
|
|
58
|
+
readonly cohortId: string;
|
|
59
|
+
readonly reason: string;
|
|
60
|
+
};
|
|
61
|
+
readonly [OrchestrationEventType.DelegationReconciliationFailed]: {
|
|
62
|
+
readonly cohortId: string;
|
|
63
|
+
readonly reason: string;
|
|
64
|
+
};
|
|
65
|
+
readonly [OrchestrationEventType.DelegationReserved]: DelegationReservation;
|
|
66
|
+
readonly [OrchestrationEventType.DelegationRegistered]: {
|
|
67
|
+
readonly cohortId: string;
|
|
68
|
+
};
|
|
69
|
+
readonly [OrchestrationEventType.DelegationResultSelected]: DelegationResult;
|
|
70
|
+
readonly [OrchestrationEventType.DelegationWaitStarted]: {
|
|
71
|
+
readonly cohortId: string;
|
|
72
|
+
readonly activationId: ActivationId;
|
|
73
|
+
};
|
|
74
|
+
readonly [OrchestrationEventType.DelegationJoined]: {
|
|
75
|
+
readonly cohortId: string;
|
|
76
|
+
readonly results: readonly DelegationResult[];
|
|
77
|
+
};
|
|
39
78
|
readonly [OrchestrationEventType.InstanceStarted]: {
|
|
40
79
|
readonly workItemId: WorkItemId;
|
|
41
80
|
readonly workflowName: WorkflowName;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { signalName } from './identifiers.js';
|
|
2
2
|
export const OrchestrationEventType = {
|
|
3
|
+
DelegationReserved: 'orchestration.delegation-reserved',
|
|
4
|
+
DelegationRegistered: 'orchestration.delegation-registered',
|
|
5
|
+
DelegationResultSelected: 'orchestration.delegation-result-selected',
|
|
6
|
+
DelegationWaitStarted: 'orchestration.delegation-wait-started',
|
|
7
|
+
DelegationJoined: 'orchestration.delegation-joined',
|
|
8
|
+
DelegationFailed: 'orchestration.delegation-failed',
|
|
9
|
+
DelegationReconciliationFailed: 'orchestration.delegation-reconciliation-failed',
|
|
3
10
|
WorkflowDefinitionRegistered: 'orchestration.workflow-definition-registered',
|
|
4
11
|
InstanceStarted: 'orchestration.instance-started',
|
|
5
12
|
StageEntered: 'orchestration.stage-entered',
|
|
@@ -11,6 +18,7 @@ export const OrchestrationEventType = {
|
|
|
11
18
|
ActivityWaiting: 'orchestration.activity-waiting',
|
|
12
19
|
SignalWaitStarted: 'orchestration.signal-wait-started',
|
|
13
20
|
SignalAccepted: 'orchestration.signal-accepted',
|
|
21
|
+
SignalDeferred: 'orchestration.signal-deferred',
|
|
14
22
|
SupplementalActivityQueued: 'orchestration.supplemental-activity-queued',
|
|
15
23
|
SupplementalActivityDequeued: 'orchestration.supplemental-activity-dequeued',
|
|
16
24
|
RepeatCounted: 'orchestration.repeat-counted',
|
|
@@ -50,6 +50,14 @@ export interface WorkflowInstanceView {
|
|
|
50
50
|
readonly triggerId?: string;
|
|
51
51
|
readonly causalCycleId?: string;
|
|
52
52
|
readonly requestId?: string;
|
|
53
|
+
readonly delegationFence?: {
|
|
54
|
+
readonly cohortId: string;
|
|
55
|
+
readonly activationId: ActivationId;
|
|
56
|
+
};
|
|
57
|
+
readonly delegationWait?: {
|
|
58
|
+
readonly cohortId: string;
|
|
59
|
+
readonly activationId: ActivationId;
|
|
60
|
+
};
|
|
53
61
|
readonly status: WorkflowStatus;
|
|
54
62
|
readonly blockReason?: string;
|
|
55
63
|
readonly currentStage: StageName;
|
|
@@ -47,3 +47,6 @@ export declare const ConversationSurfaceCapability: {
|
|
|
47
47
|
readonly Operator: "operator-surface";
|
|
48
48
|
};
|
|
49
49
|
export type ConversationSurfaceCapability = ValueOf<typeof ConversationSurfaceCapability>;
|
|
50
|
+
export declare const DelegationOutputKind: {
|
|
51
|
+
readonly Change: "change";
|
|
52
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ActivityOutcomeKind } from '../../activities/index.js';
|
|
2
|
+
import { WorkflowStatus } from '../contracts/vocabulary.js';
|
|
3
|
+
/** Configured terminal completion may follow a custom outcome or a satisfied signal gate. */
|
|
4
|
+
export function isSuccessfulWorkflowCompletion(view) {
|
|
5
|
+
return (view.status === WorkflowStatus.Completed &&
|
|
6
|
+
view.lastOutcome?.kind !== ActivityOutcomeKind.Failed &&
|
|
7
|
+
view.lastOutcome?.kind !== ActivityOutcomeKind.Blocked &&
|
|
8
|
+
view.lastOutcome?.kind !== ActivityOutcomeKind.Rejected);
|
|
9
|
+
}
|
|
@@ -22,6 +22,8 @@ export type MutableWorkflowInstance = {
|
|
|
22
22
|
triggerId?: string;
|
|
23
23
|
causalCycleId?: string;
|
|
24
24
|
requestId?: string;
|
|
25
|
+
delegationFence?: WorkflowInstanceView['delegationFence'];
|
|
26
|
+
delegationWait?: WorkflowInstanceView['delegationWait'];
|
|
25
27
|
status: WorkflowInstanceView['status'];
|
|
26
28
|
blockReason?: string;
|
|
27
29
|
currentStage: WorkflowInstanceView['currentStage'];
|
|
@@ -11,6 +11,7 @@ import { ActivityActivationStatus, WorkflowStatus } from '../contracts/vocabular
|
|
|
11
11
|
*/
|
|
12
12
|
export const orchestrationStatusTransitions = {
|
|
13
13
|
[OrchestrationEventType.ActivityRequested]: WorkflowStatus.Active,
|
|
14
|
+
[OrchestrationEventType.DelegationWaitStarted]: WorkflowStatus.Waiting,
|
|
14
15
|
[OrchestrationEventType.ActivityWaiting]: WorkflowStatus.Waiting,
|
|
15
16
|
[OrchestrationEventType.SignalWaitStarted]: WorkflowStatus.Waiting,
|
|
16
17
|
[OrchestrationEventType.SignalAccepted]: WorkflowStatus.Active,
|
|
@@ -127,11 +128,13 @@ function applyLifecycleFact(state, event) {
|
|
|
127
128
|
state.retryCounts[event.payload.retryKey] = event.payload.count;
|
|
128
129
|
return;
|
|
129
130
|
case OrchestrationEventType.InstanceCompleted:
|
|
131
|
+
delete state.delegationWait;
|
|
130
132
|
state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceCompleted];
|
|
131
133
|
delete state.pendingActivation;
|
|
132
134
|
delete state.waitingFor;
|
|
133
135
|
return;
|
|
134
136
|
case OrchestrationEventType.InstanceBlocked:
|
|
137
|
+
delete state.delegationWait;
|
|
135
138
|
state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceBlocked];
|
|
136
139
|
state.blockReason = event.payload.reason;
|
|
137
140
|
return;
|
|
@@ -139,19 +142,49 @@ function applyLifecycleFact(state, event) {
|
|
|
139
142
|
state.operatorRetryCommandIds.push(event.payload.commandId);
|
|
140
143
|
return;
|
|
141
144
|
case OrchestrationEventType.InstanceSuperseded:
|
|
145
|
+
delete state.delegationWait;
|
|
142
146
|
state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceSuperseded];
|
|
143
147
|
return;
|
|
144
148
|
default:
|
|
145
149
|
assertNever(event);
|
|
146
150
|
}
|
|
147
151
|
}
|
|
152
|
+
function applyDelegationFact(state, event) {
|
|
153
|
+
if (event.eventType === OrchestrationEventType.DelegationJoined) {
|
|
154
|
+
delete state.delegationWait;
|
|
155
|
+
delete state.delegationFence;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
state.delegationWait = event.payload;
|
|
159
|
+
state.status = WorkflowStatus.Waiting;
|
|
160
|
+
}
|
|
161
|
+
// Exhaustive dispatch over the closed coordination event set.
|
|
162
|
+
// eslint-disable-next-line complexity
|
|
148
163
|
function applyCoordinationFact(state, event) {
|
|
149
164
|
switch (event.eventType) {
|
|
150
165
|
case OrchestrationEventType.InstanceStarted:
|
|
151
166
|
case OrchestrationEventType.ChildRequested:
|
|
152
167
|
case OrchestrationEventType.ChildStarted:
|
|
153
168
|
case OrchestrationEventType.GroupBudgetExhausted:
|
|
169
|
+
case OrchestrationEventType.DelegationFailed:
|
|
170
|
+
delete state.delegationFence;
|
|
171
|
+
return;
|
|
172
|
+
case OrchestrationEventType.DelegationReconciliationFailed:
|
|
173
|
+
case OrchestrationEventType.SignalDeferred:
|
|
174
|
+
return;
|
|
175
|
+
case OrchestrationEventType.DelegationReserved:
|
|
176
|
+
if (event.payload.parentWorkflowInstanceId === state.workflowInstanceId)
|
|
177
|
+
state.delegationFence = {
|
|
178
|
+
cohortId: event.payload.cohortId,
|
|
179
|
+
activationId: event.payload.activationId,
|
|
180
|
+
};
|
|
181
|
+
return;
|
|
182
|
+
case OrchestrationEventType.DelegationRegistered:
|
|
183
|
+
case OrchestrationEventType.DelegationResultSelected:
|
|
154
184
|
return;
|
|
185
|
+
case OrchestrationEventType.DelegationWaitStarted:
|
|
186
|
+
case OrchestrationEventType.DelegationJoined:
|
|
187
|
+
return applyDelegationFact(state, event);
|
|
155
188
|
case OrchestrationEventType.ChildCompleted:
|
|
156
189
|
state.childCompletionRecorded = true;
|
|
157
190
|
return;
|
|
@@ -217,6 +250,8 @@ function applyActivityRequested(state, payload) {
|
|
|
217
250
|
...(payload.watchDriven === true ? { watchDriven: true } : {}),
|
|
218
251
|
};
|
|
219
252
|
}
|
|
253
|
+
// One optional-field projection per view property; branching mirrors the view shape.
|
|
254
|
+
// eslint-disable-next-line complexity
|
|
220
255
|
export function immutableWorkflowInstanceView(state) {
|
|
221
256
|
return {
|
|
222
257
|
workflowInstanceId: state.workflowInstanceId,
|
|
@@ -233,6 +268,8 @@ export function immutableWorkflowInstanceView(state) {
|
|
|
233
268
|
...(state.triggerId === undefined ? {} : { triggerId: state.triggerId }),
|
|
234
269
|
...(state.causalCycleId === undefined ? {} : { causalCycleId: state.causalCycleId }),
|
|
235
270
|
...(state.requestId === undefined ? {} : { requestId: state.requestId }),
|
|
271
|
+
...(state.delegationFence === undefined ? {} : { delegationFence: state.delegationFence }),
|
|
272
|
+
...(state.delegationWait === undefined ? {} : { delegationWait: state.delegationWait }),
|
|
236
273
|
status: state.status,
|
|
237
274
|
...(state.blockReason === undefined ? {} : { blockReason: state.blockReason }),
|
|
238
275
|
currentStage: state.currentStage,
|
|
@@ -32,3 +32,5 @@ export * from './domain/workflow-instance.js';
|
|
|
32
32
|
export * from './domain/workflow-selector.js';
|
|
33
33
|
export * from './application/work-completion-summary.js';
|
|
34
34
|
export type { WorkflowCompileDiagnostic } from './domain/compile-diagnostics.js';
|
|
35
|
+
export type { DelegationArtifacts, DelegationRepositories } from './contracts/delegation-ports.js';
|
|
36
|
+
export { DelegationPendingError } from './contracts/delegation.js';
|
|
@@ -31,3 +31,4 @@ export * from './domain/interpreter.js';
|
|
|
31
31
|
export * from './domain/workflow-instance.js';
|
|
32
32
|
export * from './domain/workflow-selector.js';
|
|
33
33
|
export * from './application/work-completion-summary.js';
|
|
34
|
+
export { DelegationPendingError } from './contracts/delegation.js';
|